作者handsomegirl (薰)
看板perl
标题Re: [问题] 把txt写入excel的问题
时间Tue Jul 31 11:35:14 2007
这是之前问题的延续吧...
#!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
1F:推 LiloHuang:会学Perl的通常都很少会去碰EXCEL...找到的资料当然少 07/31 18:16
3F:→ LiloHuang:绝对比EXCEL画的漂亮而且功能完整 07/31 18:17