Merge afc047221d into 8459666841
This commit is contained in:
3 files changed
+16
-5
No files matched your search
@@ -7,6 +7,7 @@ use Box\Spout\Common\Entity\Row;
|
||||
use Box\Spout\Common\Entity\Style\Style;
|
||||
use Box\Spout\Common\Exception\UnsupportedTypeException;
|
||||
use Box\Spout\Common\Type;
|
||||
use Box\Spout\Writer\Common\Creator\Style\StyleBuilder;
|
||||
use Box\Spout\Writer\WriterInterface;
|
||||
|
||||
/**
|
||||
@@ -101,9 +102,17 @@ class WriterEntityFactory
|
||||
*/
|
||||
public static function createRowFromArray(array $cellValues = [], Style $rowStyle = null)
|
||||
{
|
||||
$cells = \array_map(function ($cellValue) {
|
||||
return new Cell($cellValue);
|
||||
}, $cellValues);
|
||||
$format = $rowStyle?->getFormat();
|
||||
$cellStyles = [];
|
||||
|
||||
if (is_array($format)) {
|
||||
foreach ($format as $k => $f)
|
||||
$cellStyles[$k] = (new StyleBuilder())->setFormat($f ?? '@')->build();
|
||||
}
|
||||
|
||||
$cells = \array_map(function ($k, $cellValue) use ($cellStyles) {
|
||||
return new Cell($cellValue, $cellStyles[$k] ?? null);
|
||||
}, array_keys(array_values($cellValues)), $cellValues);
|
||||
|
||||
return new Row($cells, $rowStyle);
|
||||
}
|
||||
|
||||
@@ -141,7 +141,9 @@ class StyleRegistry extends \Box\Spout\Writer\Common\Manager\Style\StyleRegistry
|
||||
$styleId = $style->getId();
|
||||
|
||||
$format = $style->getFormat();
|
||||
if ($format) {
|
||||
|
||||
// If format is passed as array then skip it from add it to rowstyles
|
||||
if (!is_array($format)) {
|
||||
$isFormatRegistered = isset($this->registeredFormats[$format]);
|
||||
|
||||
// We need to track the already registered format definitions
|
||||
|
||||
Reference in new issue
Block a user