Windows 7:“Excel 发现无法读取的内容”
我使用 PHPExcel 生成一个非常简单的 .xls 文件 (PHPExcel_IOFactory::createWriter($PHPExcel, 'Excel5')
)。每当使用 Excel 2010 或 2007 在 Windows 7 上打开该文件时,我都会收到以下错误:
Excel 在“XXXXXXX.xls”中发现了不可读的内容。您想恢复该工作簿的内容吗?如果您信任此工作簿的来源,请单击“是”。
当我在 Windows XP 中的 Excel 2010 中打开同一文件时,它工作正常。如果我在 OpenOffice 中打开同一个文件,无论操作系统如何,它都可以工作。
Windows 7 / Excel 2010:错误
Windows 7 / Excel 2007:错误
Windows XP / Excel 2010:工作
Windows XP / Excel 2007:工作
任何 / OpenOffice:工作
当我告诉 PHPExcel 生成 .xlsx 文件 (PHPExcel_IOFactory:: createWriter($PHPExcel, 'Excel2007')
),它可以与上述所有组合配合使用。
我在 MS 论坛上发现了无数的帖子,它似乎只影响带有第三方库(不仅仅是 PHPExcel)生成的 Excel 文件的 Windows 7 文件。但没有人有解决办法。
我还找到了以下 MS 知识库文章,但我不熟悉底层的 Excel 规范: http:// /support.microsoft.com/kb/2411912
还有其他人经历过这种情况吗?
I'm using PHPExcel to generate a very simple .xls file (PHPExcel_IOFactory::createWriter($PHPExcel, 'Excel5')
). Whenever that file is opened on Windows 7 using Excel 2010 or 2007, I get the following error:
Excel found unreadable content in 'XXXXXXX.xls'. Do you want to recover the contents of this workbook? If you trust the source of this workbook, click Yes.
When I open the same file in Excel 2010 in Windows XP it works fine. If I open the same file in OpenOffice, it works regardless of the OS.
Windows 7 / Excel 2010: Error
Windows 7 / Excel 2007: Error
Windows XP / Excel 2010: Works
Windows XP / Excel 2007: Works
Any / OpenOffice: Works
When I tell PHPExcel to generate an .xlsx file (PHPExcel_IOFactory::createWriter($PHPExcel, 'Excel2007')
), it works fine with all the above combinaisons.
I found countless threads on the MS forums, and it seems to affect only Windows 7 files with Excel files generated by third party libraries (not just PHPExcel). But no one has a solution.
I also found the following MS KB article, but I'm not familiar with the underlying Excel specifications: http://support.microsoft.com/kb/2411912
Has anyone else experienced this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果这是您从 MS 支持站点突出显示的问题,那么它被锁定在 PHP_OLE 内部的某个位置,可能在 PHPExcel_Shared_OLE_PPS_File 类中。我已将其作为 问题 15508 在 PHPExcel 网站上提出,并将尝试运行一些调试周末在 Windows 7 机器上。
不保证快速修复:但您已经给了我如何尝试重现问题以及在哪里查找的指示。
If it is the problem you've highlighted from the MS Support site, then it's locked somewhere in the innards of PHP_OLE, probably in the PHPExcel_Shared_OLE_PPS_File class. I've raised this as Issue 15508 on the PHPExcel site, and will try to run some debugging over the weekend on a Windows 7 box.
No guarantees of a quick fix: but you've given me a pointer on how to try and recreate the problem, and where to look.
对我来说,当我使用正确的 UTF-8 编码字符串而不是 ISO-8859-1 时,它就被修复了。也许 PHPExcel 可以提示错误的编码?
For me it was fixed when I used proper UTF-8 encoded strings instead of ISO-8859-1. Maybe PHPExcel can hint about bad encodings?
您必须使用
UTF-8
编写标题、创建者、LastModifiedby 等字段。这是我的解决方案。You have to write with
UTF-8
the title, creator, LastModifiedby etc... fields. This was my solution.