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
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Box\Spout\Common\Entity\Style;
|
||||
|
||||
/**
|
||||
* Class Alignment
|
||||
* This class provides constants to work with text alignment.
|
||||
*/
|
||||
abstract class CellAlignment
|
||||
{
|
||||
const LEFT = 'left';
|
||||
const RIGHT = 'right';
|
||||
const CENTER = 'center';
|
||||
const JUSTIFY = 'justify';
|
||||
|
||||
private static $VALID_ALIGNMENTS = [
|
||||
self::LEFT => 1,
|
||||
self::RIGHT => 1,
|
||||
self::CENTER => 1,
|
||||
self::JUSTIFY => 1,
|
||||
];
|
||||
|
||||
/**
|
||||
* @param string $cellAlignment
|
||||
*
|
||||
* @return bool Whether the given cell alignment is valid
|
||||
*/
|
||||
public static function isValid($cellAlignment)
|
||||
{
|
||||
return isset(self::$VALID_ALIGNMENTS[$cellAlignment]);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user