in reply to writing after parsing

Hello Ashwitha,

As the Anonymous monk suggest it is better to go online read and find what exactly you are looking for. There are so many options to choose that can not be included in one answer.

Although that I have never worked with spreadsheets in Perl I found Spreadsheet::ParseExcel::SaveParser from CPAN written by Douglas Wilson.

I just created a sample.xls file exactly as the example in the tutorial shows which is able to duplicate your file and produce a new one with a new name.

Sample of the code provided in the tutorial:

#!/usr/bin/perl use strict; use warnings; use Spreadsheet::ParseExcel; use Spreadsheet::ParseExcel::SaveParser; # Open an existing file with SaveParser my $parser = Spreadsheet::ParseExcel::SaveParser->new(); my $template = $parser->Parse('template.xls'); # Get the first worksheet. my $worksheet = $template->worksheet(0); my $row = 0; my $col = 0; # Overwrite the string in cell A1 $worksheet->AddCell( $row, $col, 'New string' ); # Add a new string in cell B1 $worksheet->AddCell( $row, $col + 1, 'Newer' ); # Add a new string in cell C1 with the format from cell A3. my $cell = $worksheet->get_cell( $row + 2, $col ); my $format_number = $cell->{FormatNo}; $worksheet->AddCell( $row, $col + 2, 'Newest', $format_number ); # Write over the existing file or write a new file. $template->SaveAs('newfile.xls');

There are analytic instructions in the tutorial on how the code operates.

To make it work I had to also install Spreadsheet::WriteExcel module.

I hope this is close to what you where looking for.

Seeking for Perl wisdom...on the process...not there...yet!

Replies are listed 'Best First'.
Re^2: writing after parsing
by Ashwitha (Novice) on Aug 06, 2014 at 06:25 UTC
    Hello thanos1983 Thanks a lot for ur kind reply. When I try to run the above code u sent, im getting the following error. -cant call method "worksheet" on an undefined value at line 16.

      Hello Ashwitha,

      I spend some time today trying to figure out how to combine two excel files. To be honest since I am not an expert I figure it that maybe through 6-7 modules that I tried is was not possible. Again do not take my word or experience as granted because this was my first attempt on this area.

      But yesterday I was reading about "CSV files" take a look on those. I started working with them, and I think it would be easier to solve your problem like this.

      I mean read and export your excel files into a CSV file, then combine them in one common and regenerate your excel file combined. ;)

      This is the only solution that I can imagine for your problem.

      In case that you want for fun to experiment with some code that I create to test your question I have posted under. It is nothing complicated and also have included some documentation to assist you with the explanation.

      I hope my proposed solution did confused you more. My intention was to propose an alternative solution to your problem.

      Seeking for Perl wisdom...on the process...not there...yet!

        hello thanos1983, yeah the proposalit kinda confused me ;). But thanks a lot for replying.