开发者

Windows 7: "Excel found unreadable content"

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 sou开发者_StackOverflow社区rce 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?


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.


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?


You have to write with UTF-8 the title, creator, LastModifiedby etc... fields. This was my solution.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜