in reply to Re^3: Using variable files to add data into excel spreadsheet
in thread Using variable files to add data into excel spreadsheet
poj#!perl use strict; use Excel::Writer::XLSX; # Create a new Excel workbook and worksheet my $workbook = Excel::Writer::XLSX->new( 'fruits.xlsx' ); my $worksheet = $workbook->add_worksheet(); # get fruit types open FRUITS,'fruit_types.txt' or die "$!"; my @fruits = split '\s',<FRUITS>; # write column for each fruit for my $col (0..$#fruits){ my $fruit = $fruits[$col]; my $filename = $fruit.'.txt'; open IN, $filename or die "Could not open $filename : $!"; my @col = ($fruit); while (<IN>){ chomp; push @col, $_; } print "Writing column $col @col\n"; $worksheet->write_col(0,$col,\@col); } $workbook->close() or die "Error closing file: $!";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Using variable files to add data into excel spreadsheet
by rickyboy (Novice) on May 23, 2014 at 13:36 UTC | |
by poj (Abbot) on May 23, 2014 at 13:53 UTC |