PHPExcel 将 xlsx 保存到 xls,有些单元格是空白的


PHPExcel saving xlsx to xls, some cells are blank

我有通过PHPExcel将xls转换为xlsx的代码:

$objPHPexcel = PHPExcel_IOFactory::load('file.xlsx');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPexcel, 'Excel5');
$objWriter->save('new_file.xls');

但是当我打开创建的xls文件时,一些单元格是空的。可能是什么问题?谢谢!

下载原始 xlsx 文件的链接

you should use one of following as formate type.
1)Excel5 -> file format between Excel Version 95 to 2003
2)Excel2003XML -> file format for Excel 2003
3)Excel2007 -> file format for Excel 2007
and add following line at line no.3 in your code before save file statement.
$fileType=PHPExcel_IOFactory::identify("file.xlsx"); //We can get file reader type automatically using
it generate file as per your requirement.

我确实注意到其中一些单元格包含对外部文件的引用,例如单元格A23包含

='[Форма 1-2 от 15.12 ЯНВАРЬ екат.xls]НТТЗМ'!A77

从逻辑上讲,PHPExcel不能简单地访问外部文件(Форма 1-2 от 15.12 ЯНВАРЬ екат.xls)来检索数据;也不能处理对外部文件的引用。该文件甚至可能不存在;如果是这样,则加载(递归)公式中可能引用的每个外部文件都会产生很大的开销。

虽然您尚未指出新保存的文件中哪些单元格可能是空白的,但我猜它们是包含这些外部文件引用的单元格