#!/software/bin/perl BEGIN { unshift @INC, '/nfs/users/nfs_d/dmb/perl/lib' ; unshift @INC, '/nfs/users/nfs_d/dmb/perl/lib2' ; } use File::Basename ; use Algorithm::Permute ; use Spreadsheet::ParseExcel; use Getopt::Long; use Text::CSV; use strict; use warnings ; my @required_col = (0,2,13..47); GetOptions( "if=s" => \my $excel_file, "od=s" => \my $outputdir, ); my $parser = Spreadsheet::ParseExcel->new(); my $workbook = $parser->Parse($excel_file); if ( !defined $workbook ) { die $parser->error(), ".\n"; } my $newfile = $excel_file . ".csv"; my $csv = Text::CSV->new ( { eol => "\n" } ) or die "Cannot use CSV: ".Text::CSV->error_diag (); open my $fh, '>', $newfile or die "Can't open $newfile: $!"; my @worksheets = $workbook->worksheets(); warn "More than 1 worksheet found\n" if @worksheets > 1; # Only work with first page. my $worksheet = $worksheets[0]; my ( $row_min, $row_max ) = $worksheet->row_range(); # Skip header row for my $row ( 1 .. $row_max ) { my @data = map { my $cell = $worksheet->get_cell($row, $_); $cell ? $cell->value() : ''; } @required_col; print "@data\n"; $csv->print($fh, \@data); }
In reply to Re: Spreadsheet::ParseExcel assigning the column
by wind
in thread Spreadsheet::ParseExcel assigning the column
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |