awohld has asked for the wisdom of the Perl Monks concerning the following question:

I'm trying to write a large Excel file using Spreadsheet::ParseExcel::SaveParser. But I'm getting an error that says I can't write a file over 7MB.

Error:
Maximum Spreadsheet::WriteExcel filesize, 7087104 bytes, exceeded. To +create files bigger than this limit please refer to the "Spreadsheet: +:WriteExcel::Big" documentation.
I see it uses OLE::Storage_Lite in place of depreciated Spreadsheet::WriteExcel::Big to overcome the 7MB limit. I don't see how to apply the OLE::Storage_Lite from the Docs.

I'm reading a 150kb file, saving it as another name, and then writing to the new file about 55,000 rows with 26 columns.

Can someone kindly show me how I get this to work?
#!/usr/bin/perl -w use strict; use My::DB; use Spreadsheet::ParseExcel; use Spreadsheet::ParseExcel::SaveParser; use Spreadsheet::ParseExcel::SaveParser::Workbook; # make new connection to database my $dbh = My::DB->new( { server => 'my_server', db => 'my_database' } +); # data query my $sth_query = $dbh->prepare(" SELECT Data_1, Data_2 FROM My_Table WHERE 1 "); # execute query $sth_query->execute; # Open the template with SaveParser my $parser = Spreadsheet::ParseExcel::SaveParser->new; my $template = $parser->Parse('./data/worksheet_11_21_2008.xls'); my $workbook; { # SaveAs generates a lot of harmless warnings about unset # Worksheet properties. You can ignore them if you wish. local $^W = 0; # Rewrite the file or save as a new file $workbook = $template->SaveAs('./data/new_worksheet_11_21_2008 +.xls'); } # get the first worksheet my $worksheet = $workbook->sheets(0); # start writing here my $row = 7; while ( my @row = $sth_query->fetchrow ) { my ( $data_1, $data_2 ) = @row; # write the data to the excel file $worksheet->write( $row, 1, $data_1 ); $worksheet->write( $row, 2, $data_2 ); # increment to next excel row $row++; } # close workbook $workbook->close();

Replies are listed 'Best First'.
Re: File Too Big - Spreadsheet::ParseExcel::SaveParser
by jmcnamara (Monsignor) on Nov 26, 2008 at 01:34 UTC
    You should upgrade to a more recent version of Spreadsheet::WriteExcel (>= 2.18) and also make sure that you have OLE::Storage_Lite installed.

    Newer versions of Spreadsheet::WriteExcel handle the 7MB problem automatically. Upgrading to the most recent version of Spreadsheet::ParseExcel is also recommended

    --
    John.

      That worked. My old version was 1.X and the upgrade to Spreadsheet::WriteExcel was all that was needed.