Downloaded .xlsx file blank when opened with PHPExcel

Topics: Developer Forum, User Forum
Aug 9, 2012 at 9:09 PM

@MarkBaker I am downloading a dynamically created xlsx file from a server and using PHPExcel to open it and save the data to a DB.

If I try and open this file directly with PHPExcel after downloading it to my server it opens the file just fine, but it is showing as a blank or empty file even though it is not. If I download this xlsx file to my PC, open it with Excel there are no errors from Excel saying the data is corrupt.

So, as far as I know, the excel file is formatted correctly and not corrupt, but if I save that same file from Excel then upload it back to the server and try opening it again with PHPExcel it works perfect and my code does exactly what it should.

When I open both files in Excel (the one generated dynamically from the server directly, and the one I save to PC, open in Excel and just save it without any changes) they both look exactly the same, but when PHPExcel loads one it is empty, and the other works perfect.

I'm guessing the problem is how the xlsx file is being generated, and when I open it in Excel and save it, Excel is fixing this error, but there is no error thrown by PHPExcel or Excel itself so I have no clue how to find the formatting error if any.

Do you have any idea why this would happen? May I email you both files so you can take a look and see why this might be happening?

PHP version 5.3.5 / PHPExcel 1.7.7


Aug 9, 2012 at 9:37 PM

I have no ideas, how is the file being created in the first place?

If you email me the files, I'll take a look but I'm unlikely to get a chance for a few days - I'm away this weekend, and then preparing for the 1.7.8 release next week

Aug 9, 2012 at 9:58 PM

Thanks for your willingness to help. I am downloading it from an off site server through curl, so I have no access to the code generating the xlsx file. But I am pretty sure they are pulling the data from a DB and writing it to an excel file (maybe with PHPExcel) and making it available for download. The file works great for everything else, can open it through Excel, etc. with no errors but for some reason PHPExcel is showing it as an empty workbook unless I first open it directly with Excel and save it with no changes and upload it back to the server.