Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

opening an excel sheet using win32.ole

Status
Not open for further replies.

saran26

Programmer
May 20, 2008
173
US
Hi All,

I am trying to open an excel sheet by using the following command, the last variable -sheet is for the sheet number 1
--------------------------------------------------

C:\>cqperl ExcelperlImportCIT.pl -act Add -excels C:\CQTMTestScriptSample.xlsx -
rows 6 -sheet 1
--------------------------------------------------
and I use that value like this ---
----------------------------------
my $Sheet = $Book->Worksheets($cs);

----------------------------------

I get an error like this


Can't call method "Cells" on an undefined value, please help me with that.

Thanks
Saran
 
From when I used to work with Win32::OLE, it sounds like there was an error opening the file (which is why you get that error)

I seem to remember you have to do some weird escapes, like:

C:\\\CQTMTestScriptSample.xlsx

Could be wrong though (been about 6-7 years since I've worked on an NT box, as I hate the hell out of them ;))

Cheers

Andy
 
I would suspect you can get away with forward slashes just fine, try:
Code:
C:\>cqperl ExcelperlImportCIT.pl -act Add -excels C:/CQTMTestScriptSample.xlsx -
You might want to put more error checking in as well. For example, make sure the XLS file is actually open (and / or make sure there are no errors present) before trying to do anything with the data in the file.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top