
John - 2012-07-25 13:13:02
CAn you give some performance or memory handling tips when using large xlsx files (>10MB). Hitting memory problems en performance isn't that good either.
Using file with 100K lines.
Usage: need to get only data from file to input into database
Code:
[code]
$sheets = array();
$xlsx = new SimpleXLSX($inputFileName);
$getWorksheetName = $xlsx->getWorksheetName();
for ($j = 1; $j <= $xlsx->sheetsCount(); $j++) {
$sKey = strtoupper($getWorksheetName[$j - 1]);
// output worsheet 1
$cells = array();
list($cols, ) = $xlsx->dimension($j);
$counter = 1;
foreach ($xlsx->rows($j) as $r) {
for ($i = 0; $i < $cols; $i++) {
if (isset($r[$i])) {
$cellKey = $i + 1;
$cells[$counter][$cellKey] = $r[$i];
}
}
$counter++;
}
$sheets[$sKey] = array('numRows' => $counter, 'cells' => $cells);
}
unset($xlsx);
[/code]