Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Scan cells in Excel active worksheet

by gauss76 (Scribe)
on Apr 03, 2017 at 14:21 UTC ( [id://1186831]=perlquestion: print w/replies, xml ) Need Help??

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

Hi,

I have been learning Perl over the last few weeks with specific interest in being able to read Excel files on a non-windows server. I use the two packages:

use Spreadsheet::ParseExcel; use Spreadsheet::ParseXLSX;

for reading Excel .xls and .xlsx files respectively.

Recently I came across a problem that I cannot find any answer to: Is it possible to read just the cells of the active worksheet of an opened Excel file?

I know it is possible to loop over all the worksheets in the workbook and also possible to select any given worksheet by its name or number. However, in my application I only want to scan the rows and columns of the active worksheet but cannot find anyway of doing so.

Any help on this would be much appreciated.

Many thanks

gauss76

Replies are listed 'Best First'.
Re: Scan cells in Excel active worksheet
by SuicideJunkie (Vicar) on Apr 03, 2017 at 14:57 UTC

    Well, you can't parse the excel file if it hasn't yet been saved to disk...

    If you want to work with an opened file, then you would need to use excel APIs (See Win32::Ole) to control the application itself. Perhaps try running it through WINE?

      OK, I explained badly!

      The Excel file is saved to disk on the linux server.

      I use the following commands to get acces to the Excel file

      $parser   = Spreadsheet::ParseExcel->new();

      $parser   = Spreadsheet::ParseXLSX->new();

      I use one of the above depending on whether the file is .xls or .xlsx. Then I use:

      my $workbook = $parser->parse($FileName);

      It's the next part that is causing the problem. currently I loop through all worksheets with

      for my $worksheet ( $workbook->worksheets() )

      But I really only want to work with the active worksheet.

      gauss76
Re: Scan cells in Excel active workbook
by gauss76 (Scribe) on Apr 03, 2017 at 14:24 UTC

    I should have probably mentioned that I am using version 5.10.1 of Perl

    gauss76

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1186831]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (4)
As of 2024-04-23 06:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found