为什么 PHPExcel 在 Kohana 中使用时会尝试从 Excel 文件名创建类名?
我正在尝试将 PHPExcel 库构建到使用 Kohana PHP 框架构建的应用程序中。
在 Kohana 框架外部的测试应用程序中,我可以很好地创建和读取 Excel 文件。
并且在 Kohana 应用程序中,创建文件有效:
$objPHPExcel = new PHPExcel();
$objPHPExcel->getProperties()->setCreator("Test Generator")
->setTitle("Test Excel5 File");
$objPHPExcel->setActiveSheetIndex(0)->setCellValue('A1', 'Hello');
$objPHPExcel->getActiveSheet()->setTitle('Test Sheet');
$objPHPExcel->setActiveSheetIndex(0);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save('test123.xls'); //created in the root directory of application
但是,当在 Kohana 框架内尝试读取文件< /strong> 使用此代码:
$objReader = PHPExcel_IOFactory::createReader('test123.xls');
我收到此错误:
如何我阻止 PHPExcel/Kohana 尝试从 Excel 文件名创建类名?
I am trying to build the PHPExcel library into an application built with the Kohana PHP framework.
In a test app outside the Kohana framework, I can create and read Excel files fine.
And inside the Kohana application, creating a file works:
$objPHPExcel = new PHPExcel();
$objPHPExcel->getProperties()->setCreator("Test Generator")
->setTitle("Test Excel5 File");
$objPHPExcel->setActiveSheetIndex(0)->setCellValue('A1', 'Hello');
$objPHPExcel->getActiveSheet()->setTitle('Test Sheet');
$objPHPExcel->setActiveSheetIndex(0);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save('test123.xls'); //created in the root directory of application
However, when inside the Kohana framework when I try to read a file with this code:
$objReader = PHPExcel_IOFactory::createReader('test123.xls');
I get this error:
How can I prevent PHPExcel/Kohana from trying to create a class name out of the Excel file name?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
createReader() 方法需要文件类型作为参数(例如Excel2007、Excel5、Excel2003XML、OOCalc、Gnumeric、CSV),而不是文件名。
The createReader() method expects the filetype as a parameter (eg Excel2007, Excel5, Excel2003XML, OOCalc, Gnumeric, CSV), not the filename.