【发布时间】:2018-07-02 23:06:27
【问题描述】:
在我们的 cakephp 应用程序中有一个 excel 文件下载..
我刚刚为此准备了一个查看页面。
但我需要下载那个..
我该怎么做?
我想为此使用 PHPExcel 插件......
这是我使用的代码:
/** PHPExcel_IOFactory */
include '../Vendor/PHPExcel/Classes/PHPExcel/IOFactory.php';
$objReader = PHPExcel_IOFactory::createReader('HTML');
$objPHPExcel = $objReader->load('../View/Events/settlement_report_excel.html');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save("myExcelFile.xlsx");
但它显示../View/Events/settlement_report_excel.ctp is an Invalid HTML file.
我该如何克服这个问题...
【问题讨论】:
-
CTP是什么格式?它不是 PHPExcel 支持的标准文件格式之一
-
我有一个名为
settlement_report_excel.ctp的视图页面,其中有 html 表格,也有 php 代码,我需要将该表格下载为 excel ..... -
好吧,标准 PHPExcel 中没有 CTP 阅读器,所以
PHPExcel_IOFactory::createReader('CTP');应该抛出异常 -
好吧,我弄错了....
-
我编辑了我的问题,但现在我得到了这个错误......
../View/Events/attendees-list-table.html is an Invalid HTML file.