Hi



I need to obtain the used range in an Excel sheet. So I used the following subs, which they work fine.
sub Get_Last_Row { my ($Sheet) = @_; $Sheet->UsedRange->Find({What=>"*", SearchDirection=>xlPreviou +s, SearchOrder=>xlByRows})->{ +Row} } sub Get_Last_Col { my ($Sheet) = @_; $Sheet->UsedRange->Find({What=>"*", SearchDirection=>xlPreviou +s, SearchOrder=>xlByColumns}) +->{Column} }
In order for me to obtain the used range, I need to obtain the last used column and row in that xls sheet. However, The last Column's value is returned as an Interger! But this code
#my $LastRange = $LastCol.$LastRow; $LastRange = 'IV'.$LastRow; $ArrayData = $DataSheet-> Range("A1:$LastRange")->{Value};
requires the last column value to be in the format of Letter.Number!

So $LastCol will not work because its a number and I had to hard code 'IV' which I find it a bit silly.

my Question is :

1- how whould you guys solve this problem with minimal code?

2- What is the point in the Get_Last_col if it cannot be used directly?

Thanks

In reply to Win32::OLE Excel Last Column problem, by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.