http://www.perlmonks.org?node_id=261905


in reply to Win32::OLE excel

I'm not 100% sure what you're asking. It sounds like you want the size of the UsedRange? If so, have a look at the Count property of the Rows and Columns collections of the UsedRange object (How's that for an awkward sentence).

It should look something like this:

use strict; use Win32::OLE; my $ole = Win32::OLE->new('Excel.Application', 'Quit') or die "$!"; $ole->{Visible} = 1; my $xls = $ole->{Workbooks}->Open('mr.xls'); my $sheet = $xls->{Sheets}->{Template}; print $sheet->{UsedRange}->{Rows}->{Count}, " rows, ", $sheet->{UsedRange}->{Columns}->{Count}, " columns used."; __END__ Output: C:\>perl xls.pl 40 rows, 11 columns used.