in reply to insert into excel spreadsheet using win::ole excel object

Since it is a little qwirky getting started with OLE, here is some tested and verified barebones code to put a value in a cell of an excel sheet(using the default Book1.xls that is created when you open a new document in Excel.

Referencing the afformentioned documentation in excel will help explain how to accomplish the rest.

#!/perl -w use strict; use Win32::OLE; my $excel = new Win32::OLE('Excel.Application'); my $workbook = $excel->Workbooks->Open("Book1.xls"); $workbook->Worksheets('Sheet1')->Range('A1')->{Value} = 'perl writing +to Excel'; $workbook->Save(); $excel->Quit();


Grygonos

Replies are listed 'Best First'.
Re: Re: insert into excel spreadsheet using win::ole excel object
by noniekimp (Sexton) on Feb 19, 2004 at 21:16 UTC
    that worked great. thanks. i also tried this:

    $worksheet->Cells(1,1)->{Value} = "foo";