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

看板Perl作者 (薰)時間18年前 (2007/07/31 13:24), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/2 (看更多)
※ 引述《handsomegirl (薰)》之銘言: : 這是之前問題的延續吧... : #!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); ^^ 這裡改成2就可以以欄的方式畫圖了 自己試了幾次發現的,雖然不知道為什麼XD : $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." 怎麼指定x軸與數列的名稱 這就想不出來了.... -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.65.55.161
文章代碼(AID): #16hiTmxU (Perl)
討論串 (同標題文章)
文章代碼(AID): #16hiTmxU (Perl)