perl 写表格到excel,实现动态sheet个数和内容
时间:10-02
整理:3721RD
点击:
文件sn内容为:
Warning:jlfjalkjfldajflk(UID-346)
Warning:jlfjalkjfldajflk(UID-376)
Warning:jlfjalkjfldajflk(UID-348)
Warning:jlfjalkjfldajflk(UID-346)
Warning:jlfjalkjfldajflk(UID-376)
Warning:jlfjalkjfldajflk(UID-348)
想每个UID类型写到一个sheet里,然后在读去每行是判断什么类型的,写到相应的sheet里,每判断一行,相应的sheet里多一行这个warning;
在实现时,遇到问题:Can't call method "write" without a package or object reference at excel.pl line 91, <IN> line 4.
主体程序段如下:各位帮忙看下,谢谢;-)
open IN,"sn"||die "can not open the file !\n";
while (<IN>) {
if ($_ =~ /(Warning:.*\((\S+)\))/) {
$type = $2;
$content = $1;
$hash->{$type}->{$type}= $type;
$hash->{$type}->{$content} = $content;
for ($m =0,$m <=$#type,$m++) {
if($type[$j] eq $hash->{$type}->{$type}) {
$new_flag = 1;
last;
}
else {
$new_flag = 0;
print "bbbbbbbbbb\n";
}
}
if (!($new_flag)) {
$type[$k] = $hash->{$type}->{$type} ;
$hash->{$type}->{$type}->{number} =1;
$worksheetno= '$worksheet'.$k;
${worksheetno} = $workbook->add_worksheet("$type[$k]");
$worksheetno->write("B2", "$hash->{$type}->{$content}");
$worksheetno->write("C2", "$hash->{$type}->{$type}->{number}");
$count++;
$k++;
}
else {
$hash->{$type}->{$type}->{number} ++;
$worksheetno= '$worksheet'.$m;
$rowno= $hash->{$type}->{$type}->{number};
$worksheetno->write("B2", "aa");
}
}
}
Warning:jlfjalkjfldajflk(UID-346)
Warning:jlfjalkjfldajflk(UID-376)
Warning:jlfjalkjfldajflk(UID-348)
Warning:jlfjalkjfldajflk(UID-346)
Warning:jlfjalkjfldajflk(UID-376)
Warning:jlfjalkjfldajflk(UID-348)
想每个UID类型写到一个sheet里,然后在读去每行是判断什么类型的,写到相应的sheet里,每判断一行,相应的sheet里多一行这个warning;
在实现时,遇到问题:Can't call method "write" without a package or object reference at excel.pl line 91, <IN> line 4.
主体程序段如下:各位帮忙看下,谢谢;-)
open IN,"sn"||die "can not open the file !\n";
while (<IN>) {
if ($_ =~ /(Warning:.*\((\S+)\))/) {
$type = $2;
$content = $1;
$hash->{$type}->{$type}= $type;
$hash->{$type}->{$content} = $content;
for ($m =0,$m <=$#type,$m++) {
if($type[$j] eq $hash->{$type}->{$type}) {
$new_flag = 1;
last;
}
else {
$new_flag = 0;
print "bbbbbbbbbb\n";
}
}
if (!($new_flag)) {
$type[$k] = $hash->{$type}->{$type} ;
$hash->{$type}->{$type}->{number} =1;
$worksheetno= '$worksheet'.$k;
${worksheetno} = $workbook->add_worksheet("$type[$k]");
$worksheetno->write("B2", "$hash->{$type}->{$content}");
$worksheetno->write("C2", "$hash->{$type}->{$type}->{number}");
$count++;
$k++;
}
else {
$hash->{$type}->{$type}->{number} ++;
$worksheetno= '$worksheet'.$m;
$rowno= $hash->{$type}->{$type}->{number};
$worksheetno->write("B2", "aa");
}
}
}
顶起,麻烦帮忙看看~
你是用哪个pm, SpreadSheet:WriteExcel 么?
pm没用好,哪个method,