我有一个用PhpSpreadsheet读写的Excel文件。我所有的表和引用都在这个过程中消失了。是否有我需要设置为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代码中,我不应该真正地处理这些代码:
注意:未定义的偏移量:2在第3472行的/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Calculation.php中警告: trim()期望参数1是字符串,数组在第3680行的/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Calculation.php中给定
我还尝试了同一个模板的不同版本,该模板给了我这个错误:
致命错误: vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/Coordinate.php:42堆栈跟踪中的未捕获PhpOffice\PhpSpreadsheet\Exception:无效单元格坐标1):#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),对象(第42行中的vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/Coordinate.php中的PhpOffice\PhpS)


发布于 2019-06-04 07:50:45
智能对象在后台使用数据透视。我发现的唯一的方法就是用手来修饰细胞的样式。
发布于 2021-06-26 12:06:39
正在处理同样的问题,除了用手给细胞造型之外,找不到任何解决办法,正如Collie提到的那样。
我转而使用TinyButStrong插件OpenTBS:https://www.tinybutstrong.com/opentbs.php
这个插件允许我打开类似的XLSX文件,就像在PHP中用表格、下拉列表和样式显示屏幕截图一样,使用它作为模板并编辑列/添加值,而不会因为使用不同的方法而丢失任何东西。
当然,这并不包括您可能需要从PhpSpreadsheet获得的所有特性。但是对于简单的列/值编辑,这是一个很好的选择,对我来说,它也非常轻量级。
希望这能帮到任何人。
https://stackoverflow.com/questions/55907831
复制相似问题