PHPOffice/PHPExcel — pull request #188 by mlespiau (2013-05-24 14:49:35+00:00)
Title: Fix performance issue when exporting from Excel 2007 to CSV due to empty formatted columns in source and readDataOnly option is deactivated.

When exporting from Excel 2007 to CSV, some Excel files define a big list of columns in it's file worksheet. If the ReadDataOnly is deactivated, the export is extremely slow and the CSV is as big as the column definition, even though there is no data in those columns. Most of the samples where I observer this behavior has more than 14000 columns defined, but only a few dozens of columns have data.

After reviewing the code, I found that the cause of this problem is that the Excel2007 Reader iterates over all the columns to add styling information like Visible, Collapsed, OutlineLevel, Width, etc. and adds that information to the Worksheet, increasing _cachedHighestColumn variable. CSV Writer class uses that value to iterate results and causes the problem.

To reproduce, here is a test case:
http://pastebin.com/W5cUD6QC

I'll be posting a test case.

A proposed solution is to use getHighestDataColumn instead of getHighestColumn when iterating values in the Writer classes.