in reply to OLE, Excel, and PERL
I'd use Win32::OLE as OLE.pm is deprecated but that's not the problem. You must give the full path to the Excel spreadsheet before it will work.
This is not the greatest example (I haven't included any error checking) but it does work.
use strict; use warnings; use Win32::OLE; my $xlfile ='c:\windows\desktop\test\Book1.xls'; my $xl_app = Win32::OLE->new("Excel.Application"); $xl_app->{'Visible'} = 0; my $workbook = $xl_app->Workbooks->Open($xlfile); my $worksheet = $workbook->Worksheets(1); my $cellA1 = $worksheet->Range("A1")->{'Value'}; my $cellB1 = $worksheet->Range("B1")->{'Value'}; print "Cell A1 = $cellA1"; $worksheet->Range("A1")->{'value'} = "01aBcD2"; $cellA1 = $worksheet->Range("A1")->{'Value'}; print "\nCell A1 = $cellA1"; $cellA1 = uc $cellA1; print "\nCell A1 = $cellA1"; $xl_app->ActiveWorkbook->Close(0); $xl_app->Quit();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: OLE, Excel, and PERL
by Anonymous Monk on Oct 30, 2002 at 18:19 UTC | |
by Mr. Muskrat (Canon) on Oct 30, 2002 at 18:51 UTC |