It's been a while since I did Excel interactions, but I recall using the xlLastCell special cell. For example:
# Get the last cell for the sheet (address returned as absolute) my $last_cell = $worksheet->Range("A1")->EntireColumn->SpecialCells(xl +CellTypeLastCell)->{Address}; my ($max_column, $max_row) = $last_cell =~ /\$(\w+)\$(\d+)/;
Whether or not that's the most efficient way to do it... I don't know. I do also know that with some spreadsheets I ran into some very odd values -- the spreadsheet wasn't particularly large, but the last cell was reported as IT3991 or similar.
Added:
Some of the replies in this SoPW have similar approaches. Specifically, bmann's response seems to be a cleaner bit of code than my sample above.
In reply to Re: Win32::OLE Excel LastCol not working consistently
by Nkuvu
in thread Win32::OLE Excel LastCol not working consistently
by uvs
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |