Any pointers ? Monks,

Need your help once again. Initially i had a problem of consistently getting right value for last column and last row in excel file using Win32::OLE. I figured out following two cluprits.

1) If sort filters are turned on for column/s OR
2) If there are Unresolved forula for any column/s

1) If the FILTER in excel is left on. i.e Lets say there is column sort filter and if some columns are filtered then it does not give right last column using the formula presented in Excel Tips and Tricks.

Interesting thing is, it does not stop at the filtered column but it gives some random last column value and same for last row. As soon as you fix (remove/undo the sort filter) it gives right answer. </>

2) If there is any unresolved formula for the column (#REF) it gives the same error (Well, it returns a value but it is not the right value so you cannot find out unless you validate your final parsing) of not finding the right last column in excel. After resolving, it works fine.


Is there a way to clear filters & unresolved formulas before parsing or reading excel file then following formula can work. I cannot find anything on web related to this. There is something in VB(.Filters.Clear()) for clearing filters but i dont know how to translate in perl. I use perl 5.8.8 on windows
This is the code to determine Last Row and LastCol if everything is cl +ean and simple in excel file my $sheet =$oBook->Worksheets($iSheet); my $name =$oBook->Worksheets($iSheet)->{Name}; my $LastRow = $sheet->UsedRange->Find({What=>"*",SearchDirection=>xlPr +evious,SearchOrder=>xlByRows})->{Row}; my $LastCol = $sheet->UsedRange->Find({What=>"*",SearchDirection=>xlPr +evious,SearchOrder=>xlByColumns})->{Column};
Thank you in advance.
UVS

In reply to How to CLEAR Sort filters in Excel by uvs

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.