作者handsomegirl (薰)
看板perl
标题Re: [问题] 把txt写入excel的问题
时间Tue Jul 31 13:23:59 2007
※ 引述《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