我似乎在使用PHPExcel从Excel 2007工作簿中读取数据时遇到2个问题:
sample.xlsx:
+--------+-----------+-------------+
| Office | Hr no PFU | Hr $ no PFU |
+--------+-----------+-------------+
| AA01 | 18.50 | $ 13.14 |
| BW23 | 1020.03 | $ 123.23 |
+--------+-----------+-------------+
调整exampleWorkBookReader02.php(文档中提供的示例之一):
$inputFileType = 'Excel2007';
$inputFileName = './sampleData/sample.xlsx';
/** Create a new Reader of the type defined in $inputFileType **/
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
/** Load $inputFileName to a PHPExcel Object **/
$objPHPExcel = $objReader->load($inputFileName);
/** Read an array list of any custom properties for this document **/
$customPropertyList = $objPHPExcel->getProperties()->getCustomProperties();
foreach($customPropertyList as $customPropertyName) {
echo $customPropertyName,'<br />';
}
/** Read cell values **/
$sheetData = $objPHPExcel->getActiveSheet()->toArray(null, true, true, true);
var_dump($sheetData);
(顺便说一句,原始脚本使用文档中的文件输出自定义属性的列表,但不包含任何值。)
现在,我只在Excel 2007工作簿中遇到此问题。因此,这使我想知道是否错过了其中一项要求,但我不这么认为:
有没有办法检查是否缺少某些东西?
安装和启用扩展是两件事。检查是否已安装所有PHPEXcel依赖项,然后检查其配置文件或php.ini以查看是否确实启用了它们。
从PHPExcel文档中可以明显看出它确实支持Excel2007,并且还可以在您的开发环境中使用,对吗?好检查依赖项,看看那里出了什么问题。
系统日志中还存在一些错误信息。也许PHPExcel已经在抱怨这个“幕后”?
另外,您可能要考虑使用类似(或完全是)Vagrant之类的工具进行环境同步-这样,您将始终确保自己的环境在开发机和服务器上都相同。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句