Load a big excel file failed

Topics: Developer Forum, User Forum
Jan 8, 2009 at 5:45 AM
When I load a excel file has 31 cols & 3644 rows.
It can not load and output a blank in my web page.

this file size was:
same content.
1309KB   Excel2007 format
3799KB   Excel2003 format

my source code:

<?php

error_reporting(E_ALL);

/** Include path **/
set_include_path(get_include_path() . PATH_SEPARATOR . '../class');

/** PHPExcel_IOFactory */
include 'PHPExcel/IOFactory.php';


$objReader = PHPExcel_IOFactory::createReader('Excel2007');
$objReader->setReadDataOnly(true);
$objPHPExcel = $objReader->load("OB12.xlsx");
//$objReader = PHPExcel_IOFactory::createReader('Excel5');
//$objReader->setReadDataOnly(true);
//$objPHPExcel = $objReader->load("OB12.xls");
echo date('H:i:s') . " Load from Excel file<br/>";

$sheetCount = $objPHPExcel->getSheetCount();
echo date('H:i:s') . " Excel file have $sheetCount sheets<br/>";
$sheet = $objPHPExcel->getSheet(0);

// Echo memory peak usage
echo date('H:i:s') . " Peak memory usage: " . (memory_get_peak_usage(true) / 1024 / 1024) . " MB<br/>";
//
$HighestRow = $objPHPExcel->getActiveSheet()->getHighestRow();
$HighestCol = $objPHPExcel->getActiveSheet()->getHighestColumn();
//
////print_r($objPHPExcel);
for($i=1;$i<=$HighestRow;$i++){
    for($j='A';$j<=$HighestCol;$j++){
        $val = $sheet->getCell($j.$i)->getValue();
        echo $j.$i."=".$val."<br>";
    }
}
?>

Jan 8, 2009 at 5:55 AM
Edited Jan 8, 2009 at 5:56 AM
I edit my php.ini set

memory_limit = 256M

it's work.

Peak memory usage: 193 MB

 - -! only 1309KB file use 193MB memory?

it's crazy




Developer
Jan 8, 2009 at 5:58 AM
What is your memory_limit set at? Check using phpinfo(). If your peak memory usage is close to your memory limit raise it so it will not be exhausted. For example set it to 256MB or 512MB.
http://www.codeplex.com/PHPExcel/Thread/View.aspx?ThreadId=36847

We are aware of high memory usage. It is being addressed.
http://www.codeplex.com/PHPExcel/WorkItem/View.aspx?WorkItemId=6857

Jan 8, 2009 at 6:03 AM
Thank you koyama