Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Trouble using Spreadsheet::ParseExcel::SaveParser

by tangent (Parson)
on Jun 07, 2021 at 21:02 UTC ( [id://11133637]=note: print w/replies, xml ) Need Help??


in reply to Trouble using Spreadsheet::ParseExcel::SaveParser

Where you have:
my $parser = new Spreadsheet::ParseExcel::SaveParser if $add_wl == 1; my $wlTemplate = $parser->Parse("$tmpdir/$filename") if $add_wl == 1; my $worksheet; $worksheet = $workbook->worksheet(0);
I'm wondering where $workbook is coming from? Perhaps it should be:
$worksheet = $wlTemplate->worksheet(0);
Personally I would not use Spreadsheet::ParseExcel::SaveParser. It is a wrapper around Spreadsheet::ParseExcel and Spreadsheet::WriteExcel and I would just use those modules directly. Something like this.
my $parser = Spreadsheet::ParseExcel->new; my $workbook = $parser->parse( $file ); my $worksheet = $workbook->worksheet( 0 ); my $new_workbook = Spreadsheet::WriteExcel->new( $new_file ); my $new_worksheet = $new_workbook->add_worksheet; my ( $row_min, $row_max ) = $worksheet->row_range; my ( $col_min, $col_max ) = $worksheet->col_range; for my $row ( $row_min .. $row_max ) { for my $col ( $col_min .. $col_max ) { my $new_value = ''; my $cell = $worksheet->get_cell( $row, $col ); if ( $cell ) { my $value = $cell->value; if ( defined $value ) { $new_value = $value; if ( $col == $check_col && $value eq 'CUSTOMER ID' ) { # do what you need for this condition } } } $new_worksheet->write( $row, $col, $new_value ); } } $new_workbook->close;
If you can tell us what it is you wish to add to the new file we can help further.
 

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11133637]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2024-04-19 22:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found