How to convert .xlsin .csvto perl? which module for this? Is there an example for this? What is the best way to convert?
use Spreadsheet::ParseExcel;
my $xlsparser = Spreadsheet::ParseExcel->new();
my $xlsbook = $xlsparser->parse('/home/Admin/Downloads/abc.xls');
my $xls = $xlsbook->worksheet(0);
my ( $row_first, $row_last ) = $xls->row_range();
my ( $col_first, $col_last ) = $xls->col_range();
my $csv = '/home/Admin/Downloads/ram.csv';
for my $row ( $row_first .. $row_last ) {
for my $col ( $col_first .. $col_last ) {
my $cell = $xls->get_cell( $row, $col );
next unless $cell;
$csv .= $cell->unformatted();
if ($col == $col_last) {
$csv .= "\n";
} else {
$csv .= ",";
}
}
}
open(my$FH ,'>',"$csv") or die "oops!";
while (my$line = <$xlsbook>){
print $FH $line;
}
oops! in line csv.pl 23.
source
share