Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^3: Scan cells in Excel active worksheet

by huck (Prior)
on Apr 03, 2017 at 15:29 UTC ( [id://1186842]=note: print w/replies, xml ) Need Help??


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

http://search.cpan.org/~dougw/Spreadsheet-ParseExcel-0.65/lib/Spreadsheet/ParseExcel/Workbook.pm

get_active_sheet()

Return the number of the active (open) worksheet (at the time the workbook was saved. May return undef.

http://cpansearch.perl.org/src/DOUGW/Spreadsheet-ParseExcel-0.65/lib/Spreadsheet/ParseExcel/Workbook.pm

sub get_active_sheet { my $workbook = shift; return $workbook->{ActiveSheet}; }
Maybe you can work from that for parseXLSX

Replies are listed 'Best First'.
Re^4: Scan cells in Excel active worksheet
by gauss76 (Scribe) on Apr 04, 2017 at 13:07 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?

        Fantastic!!

        Many thanks for everyone's help with this...Special thanks must go to SuicideJunkie.

        The solution will really help me with my project.

        gauss76

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (3)
As of 2024-04-20 01:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found