http://qs321.pair.com?node_id=744064


in reply to Out of memory error while parsing a specific excel file

The trick is to remember that the source for these things is not secret...

...looking at Spreadsheet::ParseExcel::FmtDefault I see:

78: sub TextFmt { 79: my ( $oThis, $sTxt, $sCode ) = @_; 80: return $sTxt if ( ( !defined($sCode) ) || ( $sCode eq '_nativ +e_' ) ); 81: return pack( 'U*', unpack( 'n*', $sTxt ) ); 82: }
which gives us a clue at to what's going on.

Being an Excel file we may expect it to contain UTF-16. Line 81 clearly expects $sTxt to contain little-endian 16-bit Unicode character values, and is decoding those to a Perl "utf8" string. This is throwing warnings at you when it sees Unicode Surrogate values. It's not a good way of decoding UTF-16.

Looking at the values complained of (for example: 0xdb79, 0xdbb1, 0xd83e, ...) don't look plausible, because they correspond to Unicode code blocks which are currently undefined. So, either the data is broken, or some part of the parsing is broken.

...this doesn't tell you the cause of the problem. But hopefully it suggests where to look...

I'd try cutting down the input file, looking for the minimum size file that goes wrong. Given something small enough, you could attack the problem with the debugger...