【发布时间】:2017-12-06 18:22:19
【问题描述】:
我目前正在尝试保存一个用 PHPExcel 加载的 excel 文件。模板文件具有多个引用公式中其他工作表的工作表。模板正在从我的本地 Apache 服务器加载。加载文件后,我尝试保存它并抛出异常“单元格坐标字符串不能是单元格范围”。使用 HTML 编写器,它可以完美显示。
这是我的代码:
require_once "assets/vendors/PHPExcel/PHPExcel.php";
require_once 'assets/vendors/PHPExcel/PHPExcel/IOFactory.php';
$tmpfname = 'template_files/templateFile.xlsx';
$objReader = PHPExcel_IOFactory::createReaderForFile($tmpfname);
$objPHPExcel = $objReader->load($tmpfname);
try {
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
header("Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
header('Content-Disposition: attachment;filename="myfile.xlsx"');
header('Cache-Control: max-age=0');
$objWriter->save('php://output');
} catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
}
我希望我的模板表可以像往常一样在 PHPExcel 中下载,但无法解决这个问题。有没有其他人遇到过类似的事情?
下载的文档是完全空白的,除了打印的异常“捕获异常:单元格坐标字符串不能是单元格范围”。
【问题讨论】: