the file might have been damaged or modified

Jul 27, 2009 at 9:43 PM

This just started happening and I was wondering if there is a memory setting in php that needs to be adjusted.

I can create an excel file, but I will get this error "the file might have been damaged or modified from its original format on the excel file".  Now if I turn off some of the fields then it will go ahead and create the file. 

By turning off the fields I mean I can get fields A - Q or  fields J- Z to work, that is why it is leading me to believe that it is a memory issue.

Any help would be appreciated. 

MIke Moore

Jul 27, 2009 at 9:50 PM

This sounds strange. I have not seen this error message before. It started happening without you made any changes?

Maybe you can send me a sample file, then I will look at it tomorrow. (erik at phpexcel dot net)

Jul 27, 2009 at 10:05 PM

Yes the only thing that is getting bigger is the amount of data that is being pulled from the database. Please let me know how I can get these files to you.


Mike Moore

Jul 27, 2009 at 10:10 PM

Please send file to this email: erik at phpexcel dot net

Meanwhile, can you say what version of PHPExcel you are using? I will post back here tomorrow.

Jul 27, 2009 at 10:40 PM

[file received]

Indeed the problem was that memory was exhausted. If you open the defect xlsx file in a text editor you will see just this:

Fatal error:  Allowed memory size of 41943040 bytes exhausted
(tried to allocate 40 bytes) in /usr/share/pear/PHPExcel/Style/Fill.php
on line 356
So the Excel file should have been redirected to the client browser, but PHP memory was exhausted.

Tip 1:
It looks like PHP memory limit is 40MB. Try to increase by adding at the beginning of your script:
ini_set('memory_limit', '128M');
This may or may not work depending whether your web hosting has put memory limit restrictions via Apache. There is usually some kind of restriction.

Tip 2:
Download latest source code and test again. In many cases it will use less memory.

Jul 28, 2009 at 2:00 PM

That was the problem. Thank You Very Much!!!