bari has asked for the wisdom of the Perl Monks concerning the following question:

I have excel sheet with 4 colomns, i have to extract 2 coloumn based on 4 the colomn. how do i do that? do i have to connect to the database or just can get it from sheet? Thanks alot in advance.
  • Comment on how do i extract data from excel sheet?

Replies are listed 'Best First'.
Re: how do i extract data from excel sheet?
by Trinary (Pilgrim) on Dec 30, 2000 at 03:21 UTC
    My first piece of advice would be to try to get the data exported from excel in tab-separated or comma-separated formats, so you don't have to touch the actual excel file. Those file formats are a MESS. If that's not feasable, quick search of CPAN produces Spreadsheet::ParseExcel

    Enjoy

    Trinary

Re: how do i extract data from excel sheet?
by Fastolfe (Vicar) on Dec 30, 2000 at 03:41 UTC
    In addition to the advice just above, you may also be interested in making use of OLE automation if your script is running under Windows. See Win32::OLE. You don't give us any details as to what you're trying to do (get at an Excel file itself or interact with a running copy of excel), so one of these posts should have the information you need.

    As far as "database" stuff goes, you may be confusing Excel with Access. To my knowledge, Excel doesn't "export" its worksheets with any database-ish mechanism at all.

      As far as "database" stuff goes, you may be confusing Excel with Access. To my knowledge, Excel doesn't "export" its worksheets with any database-ish mechanism at all.

      No, that's true, but you can use ODBC (and therefore Win32::ODBC), for example, to read from an Excel worksheet.
      As far as "database" stuff goes, you may be confusing Excel with Access. To my knowledge, Excel doesn't "export" its worksheets with any database-ish mechanism at all.

      Data in Excel is stored in a database-like format although this mechanism is a secondary feature. It is there to allow DB applications to read the data although Excel itself doesn't strictly require it. You can access Excel data for reading and writing using ODBC or ADO.

      John.
      --
Re: how do i extract data from excel sheet?
by dws (Chancellor) on Dec 30, 2000 at 04:44 UTC
    There's an example in the Win32::OLE.pm documentation (which, interestingly enough, is in POD form in Win32::OLE.pm).

    Search for "Here is a simple Microsoft Excel application."