[perl]代码库
QUOTE:
#!/usr/bin/perl -w
use strict;
use Spreadsheet::ParseExcel;
use Spreadsheet::ParseExcel::FmtUnicode;
#gb support
my $oExcel = new Spreadsheet::ParseExcel;
die "You must provide a filename to $0 to be parsed as an Excel file" unless @ARGV;
my $code = $ARGV[1] || "CP936";
#gb support
my $oFmtJ = Spreadsheet::ParseExcel::FmtUnicode->new ( Unicode_Map => $code );
#gb support
my $oBook = $oExcel->Parse ( $ARGV[0], $oFmtJ );
my ( $iR, $iC, $oWkS, $oWkC );
print "FILE :", $oBook-> {File} , "\n";
print "COUNT :", $oBook-> {SheetCount} , "\n";
print "AUTHOR:", $oBook-> {Author} , "\n"
if defined $oBook-> {Author};
for ( my $iSheet=0; $iSheet < $oBook-> {SheetCount} ; $iSheet++ )
{
$oWkS = $oBook-> {Worksheet}[$iSheet];
print "--------- SHEET:", $oWkS-> {Name}, "\n";
for ( my $iR = $oWkS-> {MinRow} ;
defined $oWkS-> {MaxRow} && $iR <= $oWkS-> {MaxRow} ;
$iR++ )
{
for ( my $iC = $oWkS-> {MinCol} ;
defined $oWkS-> {MaxCol} && $iC <= $oWkS-> {MaxCol} ;
$iC++ )
{
$oWkC = $oWkS-> {Cells}[$iR][$iC];
print "( $iR , $iC ) =>", $oWkC->Value, "\n" if ( $oWkC );
}
}
}
by: 发表于:2017-09-12 14:54:34 顶(0) | 踩(0) 回复
??
回复评论