Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re: How to extract data from Excel by using Win32 OLE

by davies (Parson)
on Dec 14, 2013 at 23:16 UTC ( #1067186=note: print w/replies, xml ) Need Help??

in reply to How to extract data from Excel by using Win32 OLE

Unlike Excel, Perl is case sensitive. Assuming that your code posted here is exactly as in your problem, case looks like being part of the issue. My code (again, assuming everything else is correct) would be $Sheet->Cells($row_num,$label_hash_ref->{'alt'})->Value;. Braces around Value are optional. If this isn't your problem, try finding out what those cell co-ordinates are and querying that cell explicitly. I suspect you're not giving us all the information we need. I've never seen a pure integer with a leading zero returned from Win32::OLE in the way you describe.


John Davies

Replies are listed 'Best First'.
Re^2: How to extract data from Excel by using Win32 OLE
by plagent (Novice) on Dec 16, 2013 at 06:09 UTC
    Hi John, I changed to the upcase, but it still kept same, so I think this is not my problem. I think my co-ordinations, as specified in $row_num and $label_hash_ref->{'alt'}, are right because nearby values in different columns are extracted correctly. Because it is the only line to extract data from Excel files, I am still not sure how to do next. Thanks in advance.

      I can't reproduce your problem. The following code works for me:

      use strict; use warnings; use Win32::OLE; my $xl = Win32::OLE->new('Excel.Application'); $xl->{Visible} = 1; my $wb = $xl->Workbooks->Add; for my $nSht (2..$wb->Sheets->{Count}) { $wb->Sheets(2)->Delete; } my $Sheet = $wb->Sheets(1); $Sheet->Cells(2,2)->{Value} = 0.898124; print $Sheet->Cells(2,2)->Value; $xl->{DisplayAlerts} = 0; $xl->Quit;

      If you can't solve your problem from this, please post your own SSCCE (, otherwise I, at least, will be able to do little more.


      John Davies

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1067186]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2018-06-18 06:42 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (109 votes). Check out past polls.