因为工作当中遇到要处理大数据的excel的玩意,最多的有几十万行。用perl的方式试试,看看效果如何。

ppm install OLE::Storage_Lite #如果不安装这个,后面两个安装不了 
ppm install Spreadsheet::ParseExcel
ppm install Spreadsheet::WriteExcel

查看是否安装成功

perldoc Spreadsheet::ParseExcel #如果打印出文档则表示安装成功

为保证编码正确

ppm install Unicode::Map
use strict; 
use Spreadsheet::ParseExcel; 
use Spreadsheet::ParseExcel::FmtUnicode; #字符编码
 
my $parser = Spreadsheet::ParseExcel->new(); 
my $formatter = Spreadsheet::ParseExcel::FmtUnicode->new(Unicode_Map=>"CP936");#设置字符编码
#my $workbook = $parser->parse('Book.xls'); 
my $workbook = $parser->parse('E:\webdev\project\perl\a.xls', $formatter);#按所设置的字符编码解析


my $log = "demo.log";

 
if ( !defined $workbook ) { 
    die $parser->error(), ".\n"; 
}

open(FILE,">$log");

for my $worksheet ( $workbook->worksheets() ) { 
 
    my ( $row_min, $row_max ) = $worksheet->row_range(); 
    my ( $col_min, $col_max ) = $worksheet->col_range(); 
 
    for my $row ( $row_min .. $row_max ) { 
        for my $col ( $col_min .. $col_max ) { 
 
            my $cell = $worksheet->get_cell( $row, $col ); 
            next unless $cell; 
            print $cell->value()," ";
            print(FILE $cell->value()."\t");
        } 
        print "\n";
        print(FILE "\n");
    } 
}

close(FILE);
View Code

相关文章:

  • 2021-12-19
  • 2021-11-13
  • 2021-06-28
猜你喜欢
  • 2022-12-23
  • 2021-05-20
  • 2021-12-28
  • 2021-12-22
  • 2021-11-30
相关资源
相似解决方案