PHPExcel_IOFactory::load() failed

Topics: Developer Forum
Sep 15, 2011 at 2:20 PM

Hello Guys,

 

I'm just new with PHPExcel. I've looked through documentation and would like to use PHPExcel to extract data from excel files (2007 xlsx format) to MySQL database.

I was able to do it with a small file (around 200 cells with data). But when i tried to parse large file - 25Mb program just fails on load method of PHPExcel_IOFactory class.

I would appreciate any suggestions how to troubleshoot this case or how to solve it.

My code is the following:

<?php
require_once 'Classes/PHPExcel/IOFactory.php';
$objPHPExcel = PHPExcel_IOFactory::load("Final.xlsx");

foreach ($objPHPExcel->getWorksheetIterator() as $worksheet)
{
	$worksheetTitle = $worksheet->getTitle();
	$highestRow = $worksheet->getHighestRow();
	$highestColumn = $worksheet->getHighestColumn();
	$highestColumnIndex = PHPExcel_Cell::columnIndexFromString($highestColumn);
	echo "<br />Table: ".$worksheetTitle." ";
	echo 'consists of ' . $highestColumnIndex . ' columns (A-' . $highestColumn . ') ';
	echo ' and ' . $highestRow . ' rows.';
	echo '<br />Data: <table border="1"><tr>';
	for ($row = 1; $row <= $highestRow; ++ $row)
	{
		echo '<tr>';
		for ($col = 0; $col < $highestColumnIndex; ++ $col)
		{
			$cell = $worksheet->getCellByColumnAndRow($col, $row);
			$val = $cell->getValue();
			echo '<td>' . $val . '</td>';
		}
		echo '</tr>';
	}
	echo '</table>';
}

?>

thanks in advance.

Dennis.

Sep 15, 2011 at 3:23 PM

seems i found a problem. Application is lacking of memory:

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 193456316 bytes) in /var/www/html/excel/Classes/PHPExcel/Reader/Excel2007.php on line 300

I'm going to change my php settings.