Skip to content

Commit

Permalink
Upgrade to PHPSpreadsheet & replace depricated function & prevent nul…
Browse files Browse the repository at this point in the history
…l since HTMLHelper does not support it anymore (#330)
  • Loading branch information
karstennilsen authored Feb 24, 2024
1 parent 2c41aae commit 3ef3fcf
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"friendsofphp/php-cs-fixer": "^v3.40.0",
"mongodb/mongodb": "^1.17",
"ocramius/package-versions": "^2.8",
"phpoffice/phpspreadsheet": "^1.29.0",
"phpoffice/phpspreadsheet": "^2.0",
"phpstan/extension-installer": "^1.3.1",
"phpstan/phpstan": "^1.10.55",
"phpstan/phpstan-doctrine": "^1.3.54",
Expand Down
3 changes: 2 additions & 1 deletion src/Exporter/Excel/ExcelExporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
namespace Omines\DataTablesBundle\Exporter\Excel;

use Omines\DataTablesBundle\Exporter\DataTableExporterInterface;
use PhpOffice\PhpSpreadsheet\Cell\CellAddress;
use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
use PhpOffice\PhpSpreadsheet\Helper;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
Expand Down Expand Up @@ -42,7 +43,7 @@ public function export(array $columnNames, \Iterator $data): \SplFileInfo
foreach ($data as $row) {
$colIndex = 1;
foreach ($row as $value) {
$sheet->setCellValueByColumnAndRow($colIndex++, $rowIndex, $htmlHelper->toRichTextObject($value));
$sheet->getCell(CellAddress::fromColumnAndRow($colIndex++, $rowIndex))->setValue($htmlHelper->toRichTextObject($value ?? ''));
}
++$rowIndex;
}
Expand Down

0 comments on commit 3ef3fcf

Please sign in to comment.