Cell alignment
This PR adds support for cell alignment for XLSX and ODS files.
You can now align the content of the cells this way:
```
use Box\Spout\Common\Entity\Style\CellAlignment;
use Box\Spout\Writer\Common\Creator\Style\StyleBuilder;
$style = (new StyleBuilder())
->setCellAlignment(CellAlignment::RIGHT)
->build();
...
```
Possible cell alignments are: LEFT, RIGHT, CENTER and JUSTIFY.
This commit is contained in:
1 parent
0a0b1f7196
commit
9f4c094fa0
12 files changed
+246
-46
No files matched your search
@@ -8,7 +8,7 @@ namespace Box\Spout\Common\Entity\Style;
|
||||
*/
|
||||
class Style
|
||||
{
|
||||
/** Default font values */
|
||||
/** Default values */
|
||||
const DEFAULT_FONT_SIZE = 11;
|
||||
const DEFAULT_FONT_COLOR = Color::BLACK;
|
||||
const DEFAULT_FONT_NAME = 'Arial';
|
||||
@@ -54,6 +54,13 @@ class Style
|
||||
/** @var bool Whether specific font properties should be applied */
|
||||
private $shouldApplyFont = false;
|
||||
|
||||
/** @var bool Whether specific cell alignment should be applied */
|
||||
private $shouldApplyCellAlignment = false;
|
||||
/** @var string Cell alignment */
|
||||
private $cellAlignment;
|
||||
/** @var bool Whether the cell alignment property was set */
|
||||
private $hasSetCellAlignment = false;
|
||||
|
||||
/** @var bool Whether the text should wrap in the cell (useful for long or multi-lines text) */
|
||||
private $shouldWrapText = false;
|
||||
/** @var bool Whether the wrap text property was set */
|
||||
@@ -325,6 +332,44 @@ class Style
|
||||
return $this->hasSetFontName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCellAlignment()
|
||||
{
|
||||
return $this->cellAlignment;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $cellAlignment The cell alignment
|
||||
*
|
||||
* @return Style
|
||||
*/
|
||||
public function setCellAlignment($cellAlignment)
|
||||
{
|
||||
$this->cellAlignment = $cellAlignment;
|
||||
$this->hasSetCellAlignment = true;
|
||||
$this->shouldApplyCellAlignment = true;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function hasSetCellAlignment()
|
||||
{
|
||||
return $this->hasSetCellAlignment;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool Whether specific cell alignment should be applied
|
||||
*/
|
||||
public function shouldApplyCellAlignment()
|
||||
{
|
||||
return $this->shouldApplyCellAlignment;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user