perl生成excel文档的格式设置

前端之家收集整理的这篇文章主要介绍了perl生成excel文档的格式设置前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
#生成excel文档
my $workbook = Spreadsheet::WriteExcel->new('/home/loganalysis/data/hudong/docSoSearch/statKeywordsTop100.xls');
#各种数据的展现格式
my $normalFormat = $workbook->add_format(border => 1,align => "center",size=>12);
my $titleFormat = $workbook->add_format(bg_color => "yellow",border => 1,align=>"center",size=>12);
my $numFormat = $workbook->add_format(num_format=>'#,##0.00',align=>"left");
my $percentFormat = $workbook->add_format(num_format=>'#,##0.00%',align=>"center");
my $urlFormat = $workbook->add_format(border => 1,align => "left",size=>12);
my $normalFormat = $workbook->add_format(border => 1,size=>12);
my $titleFormat = $workbook->add_format(border => 1,size=>12);
my $numFormat = $workbook->add_format(bg_color => "27",align=>"right",size=>12);
my $tuchuFormat = $workbook->add_format(border => 1,align=>"left",size=>12);
$tuchuFormat->set_bg_color('27');
$tuchuFormat->set_bold();
my $normalrightFormat = $workbook->add_format(border => 1,align => "right",size=>12);
#生成excel表
my $worksheet = $workbook->add_worksheet(T("百科"));
my($row,$col)=(0,0);
#初始化表头行
$worksheet->write($row,$col++,T("分类"),$titleFormat);
$worksheet->write($row,T("PV"),T("IP"),$titleFormat);
$row++;
$col=0;
$worksheet->write($row,T("某类总量"),$tuchuFormat);
$worksheet->write($row,$a,$numFormat);
$worksheet->write($row,$b,$numFormat);
$row++;
$col=0;
$worksheet->set_column(0,40);#设置列表的宽度,第0列宽40
$worksheet->set_column(1,3,30);#设置列表的宽度,第1,2列宽30
$workbook->close();

猜你在找的Perl相关文章