Phpexcel Solutions to errors when exporting Excel files _php Tutorial

Source: Internet
Author: User
Phpexcel file is an open source PHP table Operation plug-in, as long as the use of Excel data import and export of friends Most people choose this plug-in, but in the use of the problem will also appear, the following look at the problem analysis study.

Phpexcel is the most powerful open source project in PHP that imports, exports, and operates Microsoft Excel. But it is a complex system that can sometimes be difficult to control.


Phpexcel How to export Excel tables online has been a lot, this article does not repeat. However, in the use of the process, I found a puzzling problem: that is, using Phpexcel Automatic export of Excel files can sometimes be exported and open, sometimes the generated Excel file can not be opened, Excel2007 prompted "found unreadable content."

Open the generated Excel file using a text editor and find a line of hints "Fatal error:call to a member function SetValue () on a non-object in Phpexcel/calculation/formu laparser.php on line 431 ".

After careful and painful examination, it turns out that some values start with an equal sign in the text value of the cell, for example, "= = = = China Youth Daily ...", and the result is that the phpexcel is evaluated as a formula when writing to the cell, so call the formula parser to calculate the corresponding value. However, it is not possible to calculate correctly (because it is not a formula), so the resulting Excel file cannot be opened.

The solution is very simple ,

is to filter out the equal sign "=" before writing the text value to the Excel cell.

Here are two ways to fix the error:

(1) Fatal Error:maximum execution time of seconds exceeded resolve error method
Need to modify the php.ini file, if the server is using Ubuntu 9.04 Server, you can find php.ini file under/etc/php5/apache2/, if it is FreeBSD, can be in/usr/local/lib/ Locate the php.ini file below. Edit the following statement with sudo permissions:

The following statement will be:
Max_execution_time = 30
Modified to:
Max_execution_time = 300
That is, the maximum execution time for PHP scripts is extended from 30 seconds to 300 seconds.

Then restart the Apache server, if it is an Ubuntu server, you can use the following command:
Sudo/etc/init.d/apache2 restart

(2) Fatal error:allowed memory size of 16777216 bytes exhausted solution
You need to modify the php.ini file as well:

The following statement will be:
Memory_limit = 16M
Modified to:
Memory_limit = 512M

That is, the amount of memory the PHP script can request is extended from 16M to 512M. Specific figures can be determined according to their own needs.

Need to restart the Apache server as well.

It is important to note that:
(1) The above changes may present some risks, such as excessive burden to the server. So please check again to see if it is necessary to open up more memory space and longer execution time for phpexcel or other PHP programs.
(2) After modifying the php.ini, the new settings will not take effect until Apache is restarted.
(3) PHP.ini in the settings, please according to their own server situation.

http://www.bkjia.com/PHPjc/632191.html www.bkjia.com true http://www.bkjia.com/PHPjc/632191.html techarticle phpexcel file is an open source PHP table Operation plug-in, as long as the use of Excel data import and export of friends Most people choose this plugin, but in the use of the problem will appear, the following ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.