Problems saving file

Topics: Developer Forum, Project Management Forum, User Forum
Mar 28, 2009 at 1:10 PM
Edited Mar 28, 2009 at 1:50 PM

I've got a bit strange problem.. In our system we are using PHPExcel to export data tables. At the time we were building it on our DEV server everything worked fine (well, actually, sometimes we were getting "unreadable content" errors, but that was very rare cases). Now we moved to our real server and here started the headaches.. Almost everytime MS Office fails to open a PHPExcel saved file (it saves the same file successfully something like 1 out of 10 times). 

I'm just a programmer, not much of a tech guy, so could you possibly tell me what can be causing this? If it helps, I generated good and bad saved files using the code from examples. You can find them here -

Some info about our server:
PHP Version 5.2.4-2ubuntu5.5
Apache 2.0
Zip version 2.0.0
Libzip version 0.7.1

Let me know if you need anything else. Thanks in advance!
Mar 30, 2009 at 4:36 AM
Can you check with phpinfo() if you have a setting for mbstring.func_overload other than 0.

Example, phpinfo() screen shot:

Mar 30, 2009 at 5:39 AM
No, it's zero. Actually, all mb_string values are the same as in your screenshot.
Mar 30, 2009 at 6:04 AM
Hmm... This is strange as it really looked like this was the cause.

To help finding the bug, can I ask you to try the following:

In the file called 'Classes/PHPExcel/Writer/Excel5/Workbook.php', there is a function called _storeBoundsheet. Insert the following line to check the value of the $offset variable:

function _storeBoundsheet($sheetname,$offset)
var_dump($offset);  // insert this line here at the beginning

Try on both servers and post back the results you see on the screen when you run the script.

Mar 30, 2009 at 7:23 AM
On DEV server $offset value with the example code is 869 and stays constant. However, on our real server it most often evaluates to 744 (when I run the code many times, sometimes I get 869 value and the file opens).
Mar 30, 2009 at 1:36 PM
I did some tests with your script, and I found out that those values 744 and 869 are exactly what one would get with and without mbstring function overloading.

Can you try to run this simple test script. Copy the following snippet and make sure you save it as UTF-8.

echo strlen('æ');

On your test server, this should give you 2, since 'æ' takes 2 bytes in UTF-8. On your DEV server you may get 1, and rarely 2. Can you verify this?

I have not looked carefully at this, but others have reported weirdness about mbstring function overloading randomly turning on. E.g.

Some bug fixes in PHP have been carried out for similar reports so it may be worth trying to do an upgrade.