Re: [問題] 把txt寫入excel的問題
這是之前問題的延續吧...
#!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
07/31 18:16, 1F
→
07/31 18:16, , 2F
07/31 18:16, 2F
→
07/31 18:17, , 3F
07/31 18:17, 3F
討論串 (同標題文章)
以下文章回應了本文:
完整討論串 (本文為第 1 之 2 篇):
Perl 近期熱門文章
PTT數位生活區 即時熱門文章