Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re: Using Win32::OLE and Excel - Tips and Tricks

by poolboi (Acolyte)
on Jan 28, 2008 at 08:50 UTC ( #664652=note: print w/replies, xml ) Need Help??

in reply to Using Win32::OLE and Excel - Tips and Tricks

hm..i got a perl program that needs to be appended to the last row using excel how can i do this using win32::OLE? thanks
use Win32::OLE; # use existing instance if Excel is already running eval {$ex = Win32::OLE->GetActiveObject('Excel.Application')}; die "Excel not installed" if $@; unless (defined $ex) { $ex = Win32::OLE->new('Excel.Application', sub {$_[0]->Qui +t;}) or die "Oops, cannot start Excel"; } # get a new workbook $book = $ex->Workbooks->Add; $sheet = $book->Worksheets(1); # write a 2 rows by 3 columns range $y = 2; $x = 1; $sheet->Range("A$x:J$y")->{Value} = [['Date','Total (IN)','Suc +c (IN)','Pk (IN)/Hrs','Pk (OUT)/Hrs','Peak Hour','Total (OUT)','Succ +(OUT)','MO(IN)','MO(OUT)'], [$date, $total_in, $succ_in +,$pk_in,$pk_out,"$pk_hour - $pk_hour_dur hr",$total_out,$succ_out ]]; $sheet->Range("K1:L2")->{Value} = [['Pk Msg/sec','Max Pk Msg/sec'] +, [$max_pk_msg,$pk_msg]]; foreach(@parameters) { $sheet->Cells(2,9)->{Value} = [$parameter_in_array{$_}]; $sheet->Cells(2,10)->{Value} = [$parameter_out_array{$_}]; } # print "XyzzyPerl" $array = $sheet->Range("A2:I1")->{Value}; for (@$array) { for (@$_) { print defined($_) ? "$_|" : "<undef>|"; } print "\n"; } # save and exit $book->SaveAs ("C:\\Documents and Settings\\clong\\Desktop\\pe +rl\\$save_file_name.xls") ; undef $book; undef $ex;

Replies are listed 'Best First'.
Re^2: Using Win32::OLE and Excel - Tips and Tricks
by Anonymous Monk on Apr 29, 2008 at 23:43 UTC
    I was looking at this tutorial, Is there a way that I can sort a column without knowing the lowest & highest range? Thanks.
      Is there any way to define x-axis, y-axis and Chart titles, if i make chart object like $chart = $sheet->ChartObjects->Add(100, 100, 400, 300);

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://664652]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2021-10-18 20:52 GMT
Find Nodes?
    Voting Booth?
    My first memorable Perl project was:

    Results (75 votes). Check out past polls.