Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Filtering an excel.

by Thomas Kennll (Acolyte)
on Sep 02, 2012 at 11:09 UTC ( #991263=perlquestion: print w/replies, xml ) Need Help??
Thomas Kennll has asked for the wisdom of the Perl Monks concerning the following question:

Hi Im trying to automate some excel tasks.. All I need is to filter a particular column from the "dropdown box" . Once its filtered I need to get the values for the corresponding column as well.. I tried using something like below but not seem to be working. Can anyine help? $worksheet1->autofilter('A1:D51');

Original content restored above by GrandFather.

Thanks for the reply.. I used Spreadsheet::WriteExcel (autofilter). I actually wanted to read the values once the excel is filtered.. I have a very big file with many columns, I need to filter out "a column" say C and remove the blanks.. After filtering I want to find the other column values, say if column C3 has value 0.2, I want to get the value for column B3, A3..

Replies are listed 'Best First'.
Re: Filtering an excel.
by Corion (Pope) on Sep 02, 2012 at 11:21 UTC
Re: Filtering an excel.
by CountZero (Bishop) on Sep 02, 2012 at 16:15 UTC
    Assuming you already have an Excel spreadsheet, use Spreadsheet::ParseExcel::Simple to read your spreadsheet row by row. Then check the value of the 'C' column in that row and if it meets your criterium, get the value of the other columns you need.

    Spreadsheet::WriteExcel has an autofilter method, but it does NOT filter your data. It just sets up the autofilter function in the spreadsheet, so that when you next open the spreadsheet in Excel the autofilter is already installed for your use.

    Note also that you cannot "edit" an existing spreadsheet with Spreadsheet::WriteExcel: it is strictly "write only"!


    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

    My blog: Imperial Deltronics
      Thanks!! That was helpful!
Re: Filtering an excel.
by philiprbrenan (Monk) on Sep 02, 2012 at 11:24 UTC

    Or possibly you could simply dump the spreadsheet in CSV format, make all the required changes using Perl, then let Excel reload the modified CSV file.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://991263]
Approved by marto
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (7)
As of 2018-02-22 07:50 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (288 votes). Check out past polls.