I know there are already many questions similar to this one (I have read most of them), but I still haven't found a solution so I figured I'd ask my own question with specifics.
Ok, so I have spent the past two days researching and trying to parse an Excel (.xlsx) spreadsheet in php. I've tried using the PHPExcel Library, however, it times out when trying to load the spreadsheet into memory. The spreadsheet is not very large, only 240kb, but it does have 40+ worksheets each heavily formatted (i.e. cell color, font size/color, etc...). Since I don't need any of the formatting I tried $objReader->setReadDataOnly(true);
in order to ignore it, but it still times out when trying to read the file.
So my next step was to try and load only the last couple of worksheets I actually needed using, $objReader->setLoadSheetsOnly(array(42,43,44,45));
This loads successfully, but now the problem is that the last sheets are almost completely formulas which total and read data from the previous worksheets. And since I excluded those earlier worksheets in order to load the document I can't use $cell->getCalculatedValue();
when retrieving each cell's value, thus making everything else obsolete.
So my question is, is there something else I can do in order to load and read this Excel spreadsheet?
Is there another library I should try and use? Or a completely different method I should try, since my end goal is to be able to upload parts of the data to a database?
Here is a link to the particular spreadsheet I am using.
Thanks for taking the time to read this and for any help you can provide.
Ok, I figured out why it was taking so long, one partial reason might be I was using an outdated version of PHPExcel, but I believe the real culprit was I had left XDebug enabled from a previous project. Because once I disabled that the script loaded the workbook just fine at a speed of 1.5001 seconds and using 17.5 MB of memory. Thanks for the help guys, it got me looking in the right direction.
use below code
require_once 'Classes/PHPExcel.php';
$objPHPExcel = PHPExcel_IOFactory::load("myExcelFile.xls");
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'HTML');
$objWriter->writeAllSheets();
$objWriter->save('php://output');
and you still getting time out error that means that your script takes longer than 30 seconds to run, but that PHP has a limit of 30 seconds execution time
Please increase max execution time
for php script