Re: [問題] 把txt寫入excel的問題

看板Perl作者 (薰)時間18年前 (2007/07/31 11:35), 編輯推噓1(102)
留言3則, 1人參與, 最新討論串1/2 (看更多)
這是之前問題的延續吧... #!usr/bin/perl use Win32::OLE qw(in with); use Win32::OLE::Const 'Microsoft Excel'; $Win32::OLE::Warn = 3; # Start Excel and make it visible $xlApp = Win32::OLE->new('Excel.Application'); $xlApp->{Visible} = 1; # Create a new workbook $xlBook = $xlApp->Workbooks->Add; $Excel = Win32::OLE->GetActiveObject('Excel.Application') || Win32::OLE->new('Excel.Application', 'Quit'); $Sheet=$xlBook->Worksheets(1); # Our data that we will add to the workbook... open (file,"c:\\test\\chart\\ATIOFF.txt"); while(chomp($line=<file>)){ $raw++; for $data (split/ /,$line){ $cou++ ; $Sheet->Cells($raw,$cou)->{Value}= $data; } $cou=0; } $xlBook->SaveAs("c:\\test\\chart\\ATIOFF.xls"); close (file); # Write all the data at once... $rng = $xlBook->ActiveSheet->Range("G1:G24"); $chart = $xlBook->Charts->Add; $chart->SetSourceData($rng, 4); $chart->{ChartType} = 4; # 3D-pie chart $chart->Location(1, "Sheet4"); # Wait for user input... print "Press <return> to continue..."; $x = <STDIN>; # Clean up $xlBook->{Saved} = 0; $xlApp->Quit; $xlBook = 0; $xlApp = 0; print "All done." 我把我的檔案寫到了EXCEL裡面 也產生出折線圖 但是我希望以欄為數列畫圖方式 但是這樣跑出來是以列 我想請問哪一行是描述關於選擇列或欄 還有怎麼指定x軸與數列的名稱 目前我只有指定數值的範圍而已 因為關於Perl與Excel相關的資料好少 找了很久都沒有答案~希望高手幫幫忙囉 謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.65.55.161

07/31 18:16, , 1F
會學Perl的通常都很少會去碰EXCEL...找到的資料當然少
07/31 18:16, 1F

07/31 18:16, , 2F
如果要畫出漂亮的圖表 建議你http://www.advsofteng.com
07/31 18:16, 2F

07/31 18:17, , 3F
絕對比EXCEL畫的漂亮而且功能完整
07/31 18:17, 3F
文章代碼(AID): #16hgtpkA (Perl)
文章代碼(AID): #16hgtpkA (Perl)