I am producing 5 different Excel worksheets (.csv file) using Perl. I want to combine all these as one file (Excel workbook) with 5 different worksheets rather then have 5 seperate files.
here is the script i'm using now ..
here is the script i'm using now ..
Code:
#!/usr/bin/perl -w use lib "/csv2xl/lib/site_perl"; use strict; use Spreadsheet::WriteExcel; open ( TABFILE, 'Testing.csv' ) or die "Testing.csv: $!" ; #open (TABFILE, 'tab.csv') or die "tab.csv: $!"; # Create a new workbook and add a worksheet my $workbook = Spreadsheet::WriteExcel->new('output.xls'); my $worksheet = $workbook->add_worksheet('Test data'); # Set the column width for columns 200 $worksheet->set_column(0, 70, 20); # Create a format for the column headings my $header = $workbook->add_format(); $header->set_bold(); $header->set_size(10); $header->set_color('blue'); $header->set_align('left'); # Row and column are zero indexed my $row = 0; while (<TABFILE>) { chomp; # Split on single tab my @Fld = split(/,/,$_); my $col = 0; foreach my $token (@Fld) { if ( $row == 0 ) { $worksheet->write($row,$col,$token, $header); } else { $worksheet->write($row, $col,$token); } $col++; } $row++; }