標(biāo)題: 讀取excel寫入文本,顯示Out of memory [打印本頁] 作者: fikong2005 時(shí)間: 2013-03-06 11:55 標(biāo)題: 讀取excel寫入文本,顯示Out of memory 有一堆excel需要入庫,想通過perl把他寫入到文本中,然后入數(shù)據(jù)庫。
單個(gè)excel的處理邏輯如下:
sub processExcel
{
my ($file)=@_;
my $cnt=0;
my $parser = Spreadsheet:arseExcel->new();
my $formatter = Spreadsheet:arseExcel::FmtUnicode->new(Unicode_Map=>"CP936"
my $workbook = $parser->parse("$file", $formatter);
#my $workbook = $parser->parse("$file"
if ( !defined $workbook ) {
die $parser->error(), ".\n";
}
for my $worksheet ( $workbook->worksheets() ) {
$JSQ++;
open (CONTROLFILE, ">>${OutputFile}${JSQ}.log" && print "${OutputFile}${JSQ}.log\n"
or print "open ${OutputFile}${JSQ}.log failed\n";
$cnt++;
if ($cnt==$workbook->worksheet_count()) {next;} ###最后一個(gè)sheet不用寫
my ( $row_min, $row_max ) = $worksheet->row_range();
my ( $col_min, $col_max ) = $worksheet->col_range();
for my $row ( $row_min .. $row_max ) {
if ($row== $row_min){next;} ####首行去掉
for my $col ( $col_min .. $col_max ) {
my $cell = $worksheet->get_cell( $row, $col );
next unless $cell;