I'm a business analyst who does this kind of thing for a living... I pull reports from legacy systems and format them into Excel reports. I know, my life sucks.

Fortunately for me, I discovered perl and now do all my data munging outside of Excel. However, I used to write VBA macros to do the job.

If you want to find the last row in a range of data, the VBA construct is the following (assuming your block of data starts in column A):

lastRow = activeSheeet.range("A65536").end(xlUp)

This translates into perl as...

$last_row = $active_sheet->Range('A65536')->End(-4121)

(This assumes that the value of the 'xlUp' constant in VBA is constant across different copies and versions of Excel. To check, open the macro editor in Excel (F11), open the "Immediate" window under the View menu and type xlUp to obtain its value.

Alternatively, you could figure out what I could not and determine how to bring those constants into perl. I've yet to figure out how to pull that off - I know they're in the OLE Excel object, I just don't know how to reference them.

Anyone?

Hope that helped.

Cluka

In reply to Re: Error getting number of rows in excel. by cluka
in thread Error getting number of rows in excel. by monir

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.