* Add a way to disable text wrapping (Fix #247) * Fix PHPDoc boolean notation * Fix PHPDoc param notation
This commit is contained in:
parent
a07a96f523
commit
ddb7365a79
@ -209,7 +209,7 @@ Font | Bold | `StyleBuilder::setFontBold()`
|
|||||||
| Font name | `StyleBuilder::setFontName('Arial')`
|
| Font name | `StyleBuilder::setFontName('Arial')`
|
||||||
| Font size | `StyleBuilder::setFontSize(14)`
|
| Font size | `StyleBuilder::setFontSize(14)`
|
||||||
| Font color | `StyleBuilder::setFontColor(Color::BLUE)`<br>`StyleBuilder::setFontColor(Color::rgb(0, 128, 255))`
|
| Font color | `StyleBuilder::setFontColor(Color::BLUE)`<br>`StyleBuilder::setFontColor(Color::rgb(0, 128, 255))`
|
||||||
Alignment | Wrap text | `StyleBuilder::setShouldWrapText()`
|
Alignment | Wrap text | `StyleBuilder::setShouldWrapText(true|false)`
|
||||||
|
|
||||||
#### New sheet creation
|
#### New sheet creation
|
||||||
|
|
||||||
@ -259,7 +259,7 @@ $writer->setShouldUseInlineStrings(false); // will use shared strings
|
|||||||
|
|
||||||
When reading a spreadsheet containing dates or times, Spout returns the values by default as DateTime objects.
|
When reading a spreadsheet containing dates or times, Spout returns the values by default as DateTime objects.
|
||||||
It is possible to change this behavior and have a formatted date returned instead (e.g. "2016-11-29 1:22 AM"). The format of the date corresponds to what is specified in the spreadsheet.
|
It is possible to change this behavior and have a formatted date returned instead (e.g. "2016-11-29 1:22 AM"). The format of the date corresponds to what is specified in the spreadsheet.
|
||||||
|
|
||||||
```php
|
```php
|
||||||
use Box\Spout\Reader\ReaderFactory;
|
use Box\Spout\Reader\ReaderFactory;
|
||||||
use Box\Spout\Common\Type;
|
use Box\Spout\Common\Type;
|
||||||
@ -302,7 +302,7 @@ $sheetName = $sheet->getName();
|
|||||||
// Customizing the sheet name when writing
|
// Customizing the sheet name when writing
|
||||||
$sheet = $writer->getCurrentSheet();
|
$sheet = $writer->getCurrentSheet();
|
||||||
$sheet->setName('My custom name');
|
$sheet->setName('My custom name');
|
||||||
```
|
```
|
||||||
|
|
||||||
> Please note that Excel has some restrictions on the sheet's name:
|
> Please note that Excel has some restrictions on the sheet's name:
|
||||||
> * it must not be blank
|
> * it must not be blank
|
||||||
|
@ -122,7 +122,7 @@ abstract class AbstractStyleHelper
|
|||||||
protected function applyWrapTextIfCellContainsNewLine($style, $dataRow)
|
protected function applyWrapTextIfCellContainsNewLine($style, $dataRow)
|
||||||
{
|
{
|
||||||
// if the "wrap text" option is already set, no-op
|
// if the "wrap text" option is already set, no-op
|
||||||
if ($style->shouldWrapText()) {
|
if ($style->hasSetWrapText()) {
|
||||||
return $style;
|
return $style;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -269,15 +269,24 @@ class Style
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param bool|void $shouldWrap Should the text be wrapped
|
||||||
* @return Style
|
* @return Style
|
||||||
*/
|
*/
|
||||||
public function setShouldWrapText()
|
public function setShouldWrapText($shouldWrap = true)
|
||||||
{
|
{
|
||||||
$this->shouldWrapText = true;
|
$this->shouldWrapText = $shouldWrap;
|
||||||
$this->hasSetWrapText = true;
|
$this->hasSetWrapText = true;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function hasSetWrapText()
|
||||||
|
{
|
||||||
|
return $this->hasSetWrapText;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return bool Whether specific font properties should be applied
|
* @return bool Whether specific font properties should be applied
|
||||||
*/
|
*/
|
||||||
|
@ -109,15 +109,15 @@ class StyleBuilder
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Makes the text wrap in the cell if it's too long or
|
* Makes the text wrap in the cell if requested
|
||||||
* on multiple lines.
|
|
||||||
*
|
*
|
||||||
* @api
|
* @api
|
||||||
|
* @param bool $shouldWrap Should the text be wrapped
|
||||||
* @return StyleBuilder
|
* @return StyleBuilder
|
||||||
*/
|
*/
|
||||||
public function setShouldWrapText()
|
public function setShouldWrapText($shouldWrap = true)
|
||||||
{
|
{
|
||||||
$this->style->setShouldWrapText();
|
$this->style->setShouldWrapText($shouldWrap);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,7 +138,7 @@ class StyleBuilder
|
|||||||
*
|
*
|
||||||
* @api
|
* @api
|
||||||
* @param string $color ARGB color (@see Color)
|
* @param string $color ARGB color (@see Color)
|
||||||
* @return StyleBuilder
|
* @return StyleBuilder
|
||||||
*/
|
*/
|
||||||
public function setBackgroundColor($color)
|
public function setBackgroundColor($color)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user