Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^2: A simple read of XLSX into Perl

by gadi99 (Initiate)
on Feb 26, 2013 at 22:32 UTC ( [id://1020773]=note: print w/replies, xml ) Need Help??


in reply to Re: A simple read of XLSX into Perl
in thread A simple read of XLSX into Perl

UPDATE:

I tried something different :

use strict; use Win32::OLE qw(in with); use Win32::OLE::Const 'Microsoft Excel'; $Win32::OLE::Warn = 3; my $Excel = Win32::OLE->GetActiveObject('Excel.Application') || Win32: +:OLE->new('Excel.Application', 'Quit'); my $Book = $Excel->Workbooks->Open("E:\\readexcel.xlsx"); my $Sheet = $Book->Worksheets(1); my $array = $Sheet->Range("A0:C2")->{'Value'}; $Book->Close; Foreach my $ref_array (@$array) { foreach my $scalar (@$ref_array) { print "$scalar\t;" } print "\n;" }

This time I got :

E:\>perl E:\readexcel.pl Win32::OLE(0.1709) error 0x800a03ec in METHOD/PROPERTYGET "Range" at E:\readexcel.pl line 9

Is there something wrong with my OLE…?

Replies are listed 'Best First'.
Re^3: A simple read of XLSX into Perl
by dasgar (Priest) on Feb 27, 2013 at 04:55 UTC

    A couple of comments. First, the post from the Anonymous Monk is correct about the column numbering. In the OLE environment, Excel's columns and rows are 1 based and 0 based. In other words, the upper left most corner cell is row 1, column 1 or A1, depending on which cell reference scheme that you're using.

    Secondly, I personally would discourage the practice of writing your code such that it takes over an active instance of Excel. For more info, check out the posts from me and davies in "use Win32::OLE::Const" not having an effect and Perl r/w Excel with OLE. (If you believe that davies and I contradict each other in those threads, I'd recommend going with what davies says since he's far more knowledgeable with both Excel and OLE.)

      Oh my goodness! I T - W O R K S ! ! ! ! My Perl is reading the XLSX. I'm going to convert to Monkeism right now. Thank you all. I'm going to read all the docs per your advise. Hooray for the monks!
Re^3: A simple read of XLSX into Perl
by Anonymous Monk on Feb 27, 2013 at 02:42 UTC

    Hi,

    I think it may be the "A0" that is causing the problem this time.

    Try "A1" instead.

    J.C.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (11)
As of 2024-04-23 21:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found