我已经转换了一个excel文件,并暂时将其插入到文本文件中,以便我更容易正则表达式。它看起来在txt文件上的文件,但在html文件上显示不同。
示例:
“test”在html文件上显示时会转换为“test”。
我的代码:
#!/usr/bin/perl
use 5.010;
use strict;
use warnings;
use Spreadsheet::ParseExcel;
$parser = Spreadsheet::ParseExcel->new();
$workbook = $parser->parse($filename);
if ( !defined $workbook )
{
die $parser->error(), ".\n";
}
open (my $fh, ">", 'xls_file.txt') or die $!;
for my $worksheet ( $workbook->worksheets() )
{
my $name = $worksheet->get_name();
if ($name =~ m/Approved issues/gi)
{
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 $fh $cell->value(),"\t";
}
print $fh "\n\n";
}
}
}
close $fh;