excel - Error when using Spreadsheet::ParseExcel -
i 2 errors when compiling next code:
class="lang-perl prettyprint-override">#!/usr/bin/perl utilize strict; utilize warnings; utilize spreadsheet::parseexcel; $xlsparser = spreadsheet::parseexcel->new(); $xlsbook = $parser->parse('xsl_test.xls'); $xls = $xls->worksheet(0); ( $row_first, $row_last ) = $xls->row_range(); ( $col_first, $col_last ) = $xls->col_range(); $csv = ''; $row ( $row_first .. $row_last ) { #step through each row $col ( $col_first .. $col_last ) { #step through each column $cell = $xls->get_cell( $row, $col ); #get current cell next unless $cell; $csv .= $cell->unformatted(); #get cell's raw info -- no border colors or if ( $col == $col_last ) { $csv .= "\n"; #make new line @ end of row } else { $csv .= ","; } } }
errors:
global symbol "$parser" requires explicit bundle name @ line 8 global symbol "$xls" requires explicit bundle name @ line 9
i above code http://www.ehow.com/how_7352636_convert-xls-csv-perl.html, , installed excel module using: cpan spreadsheet::parseexcel spreadsheet::xlsx spreadsheet::read
what's causing error?
those errors mean using strict
, didn't declare variables my
. example, declared $xmlprser
, tried utilize $parser
, not declared. code copied has errors.
a improve place code source itself: spreadsheet::parseexcel
try:
my $parser = spreadsheet::parseexcel->new(); $xlsbook = $parser->parse('xsl_test.xls'); $xls = $xlsbook->worksheet(0);
excel perl
No comments:
Post a Comment