-2

I'm trying to create a application for load and read a large excel file (more than 60,000 rows) using PHPExcel library. I am getting internal server. It works fine upto 600 rows. But its not working for large files. Please help.

Or any other php library available to load large files.

set_time_limit(36000);

ini_set('max_execution_time', 36000);   

##$top_records is a boolean set to get just the header and the first data row (( For field Mapping))        

if (PHP_SAPI == 'cli')
    die('This example should only be run from a Web Browser');

set_include_path(get_include_path() . PATH_SEPARATOR . SITE_PATH . '/core/extLib/Excel/Classes/');

require_once (SITE_PATH . '/core/extLib/Excel/Classes/PHPExcel.php');

include (SITE_PATH . '/core/extLib/Excel/Classes/PHPExcel/IOFactory.php');
PHPExcel_Cell::setValueBinder1( new PHPExcel_Cell_AdvancedValueBinder() );
$inputFileName = $file;

$inputFileType = PHPExcel_IOFactory::identify($inputFileName);

$objReader = PHPExcel_IOFactory::createReader($inputFileType); 

$objPHPExcel = $objReader->load($inputFileName);

Thanks

pearl
  • 41
  • 5
  • Well, we could spend some time guessing what's happening or what your code is doing, or you could __post some code__ and __error messages__ and a decent description of the problem –  Jan 23 '15 at 04:44
  • Most-likely you are exceeding memory or script timeout limits. The Excel format is not very efficient, and neither are the PHP libraries for it. – Alexander O'Mara Jan 23 '15 at 04:45
  • Thanks @HoboSapiens . Please check above code – pearl Jan 23 '15 at 05:01
  • @AlexanderO'Mara I tried by changing memory limit and script time out too. – pearl Jan 23 '15 at 05:02

3 Answers3

1

I have same your problem. The problem occur when work on this line

$objPHPExcel = $objReader->load($inputFileName);

athivvat
  • 45
  • 7
0

Unfortunately PHPExcel is not meant to handle very large files. Changing the memory limit or time limit is at best a temporary fix but you will have the same problem with bigger files.

I can suggest you taking a look at Spout instead. It works great for your use case!

Adrien
  • 1,929
  • 1
  • 13
  • 23
0

Increase memory limit. (eg: ini_set('memory_limit', '512') ),

Or use chunk instead. link

ThangTD
  • 1,586
  • 17
  • 16