www.webdeveloper.com
Results 1 to 3 of 3

Thread: How to fix Fatal Error PHPExcel: Memory Limit Exhausted while reading XLSX file of 5M

  1. #1
    Join Date
    Jun 2013
    Posts
    2

    How to fix Fatal Error PHPExcel: Memory Limit Exhausted while reading XLSX file of 5M

    I am facing this problem while reading an XLSX files having 40,000 plus rows and 7 columns having 5MB+ file size with PHPExcel.

    The error description is given here:

    HTML Code:
    Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 32 bytes) in .....
    Can you please suggest me a solution to this problem?

    Thanking you in anticipation.

    Best Regards,
    Rao Rafique.

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    18,918
    You can change the max memory allotment via the memory_limit setting, either via ini_set() in the script, or in an applicable config file.

    Personally, I'd look for a way to process one line at a time instead of trying to load it all into memory, if that is practical. One way would be to save the Excel file as a CSV file, then use fopen() and fgetcsv() to read that CSV file one line at a time, processing each line individually.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  3. #3
    Join Date
    Jun 2013
    Posts
    2

    Already Memory Limit Updated

    Quote Originally Posted by NogDog View Post
    You can change the max memory allotment via the memory_limit setting, either via ini_set() in the script, or in an applicable config file.

    Personally, I'd look for a way to process one line at a time instead of trying to load it all into memory, if that is practical. One way would be to save the Excel file as a CSV file, then use fopen() and fgetcsv() to read that CSV file one line at a time, processing each line individually.
    Thanks for the reply. I have already tried the first solution i.e. changing memory_limit in php.ini But it stil does not work even setting the memory_limit= 512M.

    However, I will look for the 2nd solution that you have just suggested using fopen() with CSV.

    Looking forward. Hope to hear from you soon.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles