Take the 2-minute tour ×

I am running in to a strange issue. My export routine fails to export big PHP array to excel. The file generated only has headers but no data. It works perfectly fine if the file to be generated is below 2MB approx. Same issue happens if I try to export the array to PDF.

If I run the same script on local machine it exports perfectly fine.

Below is the code I am using.

        $arraySize = array_size($tab_item);
        header("Pragma: public");
        header("Expires: 0");
        header("Content-Disposition: attachment;filename=exported-list.csv; size=$arraySize");

        $tab_header = explode("|",$headers);
        $valueCount = count($tab_header);
        for ($z = 0; $z < $valueCount-1; $z++){
            $tab_header[$z] = mb_convert_encoding($tab_header[$z], "UTF-8");
        for ($x = 0; $x < $itemCount; $x++)
            $tab_value = explode("|",$tab_item[$x]);
            $valueCount = count($tab_value);
                $tab_value[$z] =  mb_convert_encoding($tab_value[$z], "UTF-8"); //iconv("UTF-8","ISO-8859-9",$tab_value[$z]);

            //  xlsWriteNumber($xlsRow,0,"5");

Help please.

share|improve this question
What do your log files say? Have you compared .ini files between machines? –  pgl Dec 21 '11 at 15:52
You might be hitting the execution time limit on your script. Try adding set_time_limit(0); to the beginning of it and try again. –  GigaWatt Dec 21 '11 at 15:53
@pgl I have looked in to Apache logs and it doesn't say anything. I have also compared .ini files on local and remote machine and found no difference. Do you think it can be an apache issue? –  Rahi Dec 21 '11 at 16:09
@GigaWatt I have already setup set_time_limit(0). It doesn't trigger any maximum execute time OR memory exhaust error. Thoughts? –  Rahi Dec 21 '11 at 16:10
There are several possible issues: the script is timing out, you have different versions of PHP, you're running on different platforms, you have differently configured versions of PHP - which could include the timeout settings, the max output settings, max memory usage settings, etc. –  pgl Dec 21 '11 at 16:12
show 4 more comments


Your Answer



Browse other questions tagged or ask your own question.