My life is controlled by many others--a common complaint, I'm sure. I would like to convert a series of 'xls' files to 'csv' files. I've been successful on Windows machines but some of the controlling individuals have decreed that we're transitioning to Linux. After a bit of exploration, I grabbed Spreadsheet::ParseExcel from CPAN and, still on Windows, processed a single Excel file smoothly. Solved, I thought. The next file (much less complex than the first) produced an "out of memory" error--more poking found this bit (blatantly swiped from another post) that addressed the "out of memory" problem:
#!/usr/bin/perl
use strict;
use Spreadsheet::ParseExcel;
my $parse_excel =
Spreadsheet::ParseExcel->new(CellHandler => \&cell_handler,
NotSetCell => 1);
my $workbook = $parse_excel->Parse('22 JAN 2011 CRAM CFC1.xls');
sub cell_handler
{
my $workbook = $_[0];
my $sheet_index = $_[1];
my $row = $_[2];
my $col = $_[3];
my $cell = $_[4];
# Do something useful with the formatted cell value
print $cell->{Val}, "\n";
}
Then things got too strange for this Perl duffer. The offending file (79kb) is data from another group. I can't control how it's formatted. If I save the file as a 'csv' file, open that and re-save it in the 'xls' format, the script shrinks significantly and works properly. If I save the original file as another 'xls' file its size grows to 93kb and I get a completely different error.
And, if that weren't strange enough, I have another, similar file (similar size) from the same group that produces another error and it shuts down the perl interpreter.
So, am I struggling with a ParseExcel problem or, what seems more likely to me, a problem with Excel itself? Or just simple ineptitude? Always a possibility.
Many thanks for your attention.