Ask a question about how to export data in PHPExcel on a small website developed on the local machine, use PHPExcel to export data to excel, the test is normal. But when I copy all the programs to the server, the problem arises. Originally, the data could be imported and the data could not be exported. The key is that the save file dialog box does not pop up and the data is directly output to the webpage. I have been searching for a long time and don't know why!
Export data on the local machine. normal:
After the program is copied to the server, the "save" dialog box is not displayed, but the exported data is directly output to the webpage ,:
This is what happened. after several days, I can't find the cause. I can export data on the local machine. I can also use other computers to browse my local machine and export data normally, which indicates that the code is correct, what settings should be related? has anyone ever encountered this problem? Please give me some advice. thank you!
Reply to discussion (solution)
What is the header? paste it and check it out.
...... Header ('content-Type: application/vnd. ms-excel '); header ("Content-Disposition: attachment; filename = ". "Report_PC ". $ mydate. "_". date ('mdhis '). ". xls "); header ('cache-Control: max-age = 0'); $ objWriter = PHPExcel_IOFactory: createWriter ($ objPHPExcel, 'excel5 '); $ objWriter-> save ('php: // output ');
The header is certainly okay. Today, an error is detected. the server is inconsistent with the apache and php versions on my local machine, and the server is low. Apache2.4.4 + PHP5.4.16, server Apache2.2.11 + PHP5.2.9
If the version is different, check whether some statements are not supported.
Check the compatibility of excle with php apache.