FIX: columns
This commit is contained in:
@ -12,9 +12,24 @@ class Informe
|
||||
$this->spreadsheet = new Spreadsheet();
|
||||
return $this;
|
||||
}
|
||||
protected function formatArray(array $data)
|
||||
{
|
||||
$maxCols = 0;
|
||||
foreach ($data as $row) {
|
||||
if (count($row) > $maxCols) {
|
||||
$maxCols = count($row);
|
||||
}
|
||||
}
|
||||
foreach ($data as &$row) {
|
||||
if (count($row) < $maxCols) {
|
||||
$row = array_merge($row, array_fill(0, $maxCols - count($row), ''));
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
public function addArray(array $data, string $start = 'A1')
|
||||
{
|
||||
$this->spreadsheet->getActiveSheet()->fromArray($data, null, $start);
|
||||
$this->spreadsheet->getActiveSheet()->fromArray($this->formatArray($data), null, $start);
|
||||
return $this;
|
||||
}
|
||||
public function send(string $filename)
|
||||
|
Reference in New Issue
Block a user