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.
 

In reply to Re: Trouble using Spreadsheet::ParseExcel::SaveParser by tangent
in thread Trouble using Spreadsheet::ParseExcel::SaveParser by rhysshadow

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.