PhpSpreadsheet: таблицы теряются в процессе - PullRequest
1 голос
/ 29 апреля 2019

У меня есть файл Excel, который я читаю и записываю с помощью PhpSpreadsheet. Все мои таблицы и ссылки исчезают в процессе. Есть ли флаг, который мне нужно установить в true / false, или таблицы просто не могут обрабатывать PhpSpreadsheet? Смотрите скриншоты до и после экспорта.

Я пробовал разные комбинации из истинных / ложных без удачи setIncludeCharts(true); и setPreCalculateFormulas(true)

Что-нибудь очевидно, что я здесь скучаю?

require 'vendor/autoload.php';

use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;

$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader('Xlsx');
$spreadsheet = $reader->load("template.xlsx");

header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="result.xlsx"');
header('Cache-Control: max-age=0');

$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xlsx');
$writer->save('php://output');
exit;

Я подавляю эти уведомления / предупреждения с помощью error_reporting(0), если это имеет какое-либо отношение к этому. Однако это в коде PhpSpreadsheet, с которым я не должен связываться:

Notice: Undefined offset: 2 in
/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Calculation.php
on line 3472

Warning: trim() expects parameter 1 to be string, array given in
/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Calculation.php
on line 3680

Я также попробовал другую версию того же самого шаблона, который дал мне эту ошибку:

Fatal error: Uncaught PhpOffice\PhpSpreadsheet\Exception: Invalid cell
coordinate 1))) in
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/Coordinate.php:42
Stack trace: #0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/Coordinate.php(111):
PhpOffice\PhpSpreadsheet\Cell\Coordinate::coordinateFromString('1)))')
#1 vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/Coordinate.php(86):
PhpOffice\PhpSpreadsheet\Cell\Coordinate::absoluteCoordinate('1)))')
#2 vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/Workbook.php(416):
PhpOffice\PhpSpreadsheet\Cell\Coordinate::absoluteReference('1)))') #3
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/Workbook.php(267):
PhpOffice\PhpSpreadsheet\Writer\Xlsx\Workbook->writeDefinedNameForPrintArea(Object(PhpOffice\PhpSpreadsheet\Shared\XMLWriter),
Object(PhpOffice\PhpS in
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/Coordinate.php
on line 42

enter image description here enter image description here

1 Ответ

0 голосов
/ 04 июня 2019

Smarttables используют Сводные таблицы в фоновом режиме. Единственный способ обойти, что я нашел, - это стилизовать клетки вручную.

...