1
我有一個將xlsx文件轉換爲csv文件的腳本。但我怎麼能只將一個特定(命名)工作表從一個xlsx工作簿(與多個工作表)轉換爲一個csv文件。Perl將一個指定的workseet從一個xlsx工作簿轉換爲一個csv文件
#!/usr/bin/perl
use strict;
use warnings;
use Spreadsheet::BasicRead;
use Excel::Writer::XLSX;
use Spreadsheet::ParseExcel;
my $xlsx = ("c:\\acb.xlsx"),,1;
my $csv = ("c:\\acb.csv"),,1;
if (-e $xlsx) {
my $ss2 = new Spreadsheet::BasicRead($xlsx) or die;
my $name2 = '';
my $row2 = 0;
open(FILE2, ">$csv") or die ;
binmode(FILE2, ":utf8"); # Wide character in print warnings
while (my $data2 = $ss2->getNextRow()){
$row2++;
$name2 = join(',', @$data2);
print FILE2 $name2."\n" if ($name2 ne "");
}
close FILE2;
}