Unfortunately, the code as it stands won't produce the correct results; you'll get 2 c entries for every column, and 2 row entries for every row, because you'll get both the opening and the closing tags; .... the listWorksheetInfo() code that I've been testing to work with xmlReader streaming uses:
while ($xml->read()) {if ($xml->name == 'row'&& $xml->nodeType == XMLReader::ELEMENT) { $tmpInfo['totalRows']++; $tmpInfo['totalColumns'] = max($tmpInfo['totalColumns'],$currCells); $currCells = 0; } elseif ($xml->name == 'c'&& $xml->nodeType == XMLReader::ELEMENT) { $currCells++; } }
Generally XMLReader is more memory efficient, but slower. In the case of listWorksheetInfo(), it's marginally faster than the current code because it's looping through the data in a single pass rather than the nested loops of the simpleXML method. With a test file containing 2 worksheets of 16370 rows by 9 columns, it's about 7.5-8 seconds rather than 10, and uses 1.25MB (peak at 7.5MB) rather than 2.5MB (peak at 8.75).
XMLReader streaming should povide a bigger peak memory saving, and is a lot faster than $xml->xml() to load the xml data to the reader resource, as shown in the thread http://phpexcel.codeplex.com/discussions/242712... this is still targetted for the 1.7.9 release sometime in the next couple of months.