#產生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',border => 1,align=>"left");my $percentFormat = $workbook->add_format(num_format=>'#,##0.00%',border => 1,align=>"center");my $urlFormat = $workbook->add_format(border => 1,align => "left",size=>12);
my $normalFormat = $workbook->add_format(border => 1,align => "left",size=>12);my $titleFormat = $workbook->add_format(border => 1,align=>"center",size=>12);my $numFormat = $workbook->add_format(bg_color => "27",border => 1,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,$col++,T("PV"),$titleFormat);$worksheet->write($row,$col++,T("IP"),$titleFormat);$row++;$col=0;$worksheet->write($row,$col++,T("某類總量"),$tuchuFormat);$worksheet->write($row,$col++,$a,$numFormat);$worksheet->write($row,$col++,$b,$numFormat);$row++;$col=0;
$worksheet->set_column(0,0,40);#設定列表的寬度,第0列寬40$worksheet->set_column(1,3,30);#設定列表的寬度,第1,2列寬30$workbook->close();