duanchuang1935 2019-04-29 17:00
浏览 323

PhpSpreadsheet:表格在此过程中丢失

I have an Excel file that I read and write to with PhpSpreadsheet. All my tables and references disappear in the process. Is there a flag I need to set to true/false or are tables just something that PhpSpreadsheet can't handle? See screenshots of before and after export.

I've tried different true/false combos of these without any luck setIncludeCharts(true); and setPreCalculateFormulas(true)

Anything obvious I'm missing here?

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;

I suppress these notices/warnings with error_reporting(0) if it has anything to do with it. However that is in the PhpSpreadsheet code, which I'm not really supposed to mess with:

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

I also tried a different version of the same template that gave me this error:

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条回答 默认 最新

  • duagfgfn1981 2019-06-04 07:50
    关注

    The Smarttables use Pivottables in the background. The only way to get around that I found is to style the cells by hand.

    评论

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题