Row objects and Cell styling
This commit introduces Row and Cell entities, that will replace the arrays passed in previously. It also adds support for Cell styling (instead of Row styling only).
This commit is contained in:
1 parent
fec27e9056
commit
7274226b75
32 files changed
+1113
-859
No files matched your search
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace Box\Spout\Writer;
|
||||
|
||||
use Box\Spout\Writer\Common\Creator\EntityFactory;
|
||||
use Box\Spout\Writer\Common\Entity\Row;
|
||||
use Box\Spout\Writer\Common\Entity\Style\Style;
|
||||
|
||||
/**
|
||||
* Trait RowCreationHelper
|
||||
*/
|
||||
trait RowCreationHelper
|
||||
{
|
||||
/**
|
||||
* @param array $cellValues
|
||||
* @param Style|null $rowStyle
|
||||
* @return Row
|
||||
*/
|
||||
protected function createRowFromValues(array $cellValues, Style $rowStyle = null)
|
||||
{
|
||||
$row = EntityFactory::createRow([], $rowStyle);
|
||||
|
||||
foreach ($cellValues as $cellValue) {
|
||||
$row->addCell(EntityFactory::createCell($cellValue));
|
||||
}
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $cellValues
|
||||
* @param Style $rowStyle
|
||||
* @return Row
|
||||
*/
|
||||
protected function createStyledRowFromValues(array $cellValues, Style $rowStyle)
|
||||
{
|
||||
return $this->createRowFromValues($cellValues, $rowStyle);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $rowValues
|
||||
* @param Style|null $rowsStyle
|
||||
* @return Row[]
|
||||
*/
|
||||
protected function createRowsFromValues(array $rowValues, Style $rowsStyle = null)
|
||||
{
|
||||
$rows = [];
|
||||
|
||||
foreach ($rowValues as $cellValues) {
|
||||
$rows[] = $this->createRowFromValues($cellValues, $rowsStyle);
|
||||
}
|
||||
|
||||
return $rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $rowValues
|
||||
* @param Style $rowsStyle
|
||||
* @return Row[]
|
||||
*/
|
||||
protected function createStyledRowsFromValues(array $rowValues, Style $rowsStyle)
|
||||
{
|
||||
return $this->createRowsFromValues($rowValues, $rowsStyle);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user