Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^2: Scan cells in Excel active worksheet

by gauss76 (Scribe)
on Apr 03, 2017 at 15:19 UTC ( [id://1186841]=note: print w/replies, xml ) Need Help??


in reply to Re: Scan cells in Excel active worksheet
in thread Scan cells in Excel active worksheet

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

Replies are listed 'Best First'.
Re^3: Scan cells in Excel active worksheet
by huck (Prior) on Apr 03, 2017 at 15:29 UTC

      Many thanks huck for the answer, which works fine for .xls files with the code:

      my $FileName = "Excel Test File 1.xls";

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

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

      my $Res1=get_active_sheet($workbook);

      But I have no idea how to get it to work with xlsx files, which, currently fails if I try the following:

      my $FileName = "Excel Test File 1A.xlsx";

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

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

      my $Res1=get_active_sheet($workbook);

      gauss76

        A quick peek through the source, and I spotted:

        my ($node) = $files->{workbook}->find_nodes('//s:workbookView'); my $selected = $node ? $node->att('activeTab') : undef; $workbook->{SelectedSheet} = defined($selected) ? 0+$selected : 0;
        Will $workbook->{SelectedSheet} work do the trick?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (2)
As of 2024-04-26 00:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found