#创建一个excel 解释器 my $parser = Spreadsheet::ParseExcel->new(); # 解释xls文件,得到xls文件对象 my $workbook = $parser->parse('2F.xls'); #得到excel 中所有的sheet my @sheet_objs=$workbook->worksheets(); #指定要操作的sheet,可以通过sheet名字或者index进行指定 #index 从0开始计数 my $worksheet_name=$workbook->worksheet('Worker name'); my $worksheet_1=$workbook->worksheet(0);
#获取Worker name中的详细信息 my ( $row_min, $row_max ) = $worksheet_name->row_range(); my ( $col_min, $col_max ) = $worksheet_name->col_range();
formy $row ( $row_min .. $row_max ) { formy $col ( $col_min .. $col_max ) {
my $cell = $worksheet_name->get_cell( $row, $col ); nextunless $cell;
#!/usr/perl -w use strict; use Spreadsheet::ParseExcel; #for xls use Spreadsheet::XLSX; #xlsx use Spreadsheet::WriteExcel; use Excel::Writer::XLSX;
my $workbook=Spreadsheet::XLSX->new('2F.xlsx');
#for write #分别创建xls xlsx格式文件进行写入 my $workbook_w = Excel::Writer::XLSX->new( '07.xlsx' ); my $workbook_w03=Spreadsheet::WriteExcel->new('03.xls');
#read and write formy $worksheet ( $workbook->worksheets() ) { my $worksheet_w=$workbook_w->add_worksheet(); my $worksheet_w03=$workbook_w03->add_worksheet();
my ( $row_min, $row_max ) = $worksheet->row_range(); my ( $col_min, $col_max ) = $worksheet->col_range();
formy $row ( $row_min .. $row_max ) { formy $col ( $col_min .. $col_max ) {
my $cell = $worksheet->get_cell( $row, $col ); nextunless $cell;