以下代码仅在我评论Thrid表时才有效,我可以看到打开并查看插入的内容,但是当我包含第三张表时,它不会打开文件但显示错误{{1} }。
can’t be opened for some reason.
请帮我解决这个问题。 https://github.com/PHPOffice/PhpSpreadsheet/ (开发)分支
答案 0 :(得分:0)
根据documentation,您可以尝试以下操作:
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader("Xlsx");
$spreadsheet = $reader->load('<path>'); //Path of reader sheet
// Create a new worksheet called "Name" in your case 3 Times
$myWorkSheet = new \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet($spreadsheet, 'Name');
// Attach the "Name" worksheet as the first worksheet in the Spreadsheet object
$spreadsheet->addSheet($myWorkSheet, 0);
然后您可以按名称调用工作表
$spreadsheet->getSheetByName('Name');
答案 1 :(得分:0)
尝试删除或注释掉该行
$writer->setOffice2003Compatibility(true);
就我而言,它抛出了那个错误