PHPExcel is the most powerful open-source project in PHP for importing, exporting, and operating Microsoft Excel. However, its system is complex and sometimes difficult to control.
PHPExcel has been used to export Excel tables online, so this article will not go into details. However, I found an inexplicable problem during usage: That is, using PHPExcel to automatically export excel files can sometimes be exported and opened normally, sometimes the generated excel file cannot be opened, and Excel2007 prompts "unreadable content found ".
Open the generated Excel file in the text editor, and a message "Fatal error: Call to a member function setValue () on a non-object in PHPExcel/Calculation/FormulaParser" is displayed. php on line 431 ".
After careful and painful checks, it turns out that some values start with an equal sign in the text value of the written cell, for example, "==== China Youth Daily... ", when PHPExcel writes the cell, it determines it as a formula, and calls the formula parser to calculate the corresponding value, however, the generated excel file cannot be opened because it is not a formula.
The solution is very simple.,
Filter out the equal sign "=" before writing text values to an excel cell.
There are two possible solutions:
(1) Fatal error: Maximum execution time of 30 seconds exceeded solution
Php needs to be modified. ini file. If you are using a Ubuntu 9.04 Server, you can find php under/etc/php5/apache2. ini file. For Freebsd, you can find php under/usr/local/lib. ini file. Use the sudo permission to edit the following statement:
Run the following statement:
Max_execution_time = 30
To:
Max_execution_time= 300
That is, the maximum execution time of PHP scripts is extended from 30 seconds to 300 seconds.
Restart the Apache Server. If it is a Ubuntu Server, run the following command:
Sudo/etc/init. d/apache2 restart
(2) Fatal error: Allowed memory size of 16777216 bytes exhausted solution
Similarly, you need to modify the php. Ini file:
Run the following statement:
Memory_limit = 16 M
To:
Memory_limit = 512 M
That is, to increase the memory size that PHP scripts can apply for from 16 MB to 512 MB. The specific number can be determined based on your own needs.
Restart the Apache server.
Note that:
(1) The above modifications may have certain risks, such as causing too much burden on the server. Therefore, please confirm whether it is necessary to open more memory and longer execution time to PHPExcel or other PHP programs.
(2) after modifying php. ini, the new settings will take effect only after Apache is restarted.
(3) in php. ini, please do your best according to your server.