in reply to Win32::OLE Excel LastCol not working consistently
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Win32::OLE Excel LastCol not working consistently
by uvs (Novice) on Oct 25, 2007 at 19:47 UTC | |
by uvs (Novice) on Oct 25, 2007 at 20:34 UTC |