Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: parse only one sheet at time In Spreadsheet::ParseExcel

by Kenosis (Priest)
on Jan 30, 2013 at 23:39 UTC ( #1016179=note: print w/ replies, xml ) Need Help??


in reply to parse only one sheet at time In Spreadsheet::ParseExcel

Here are two examples, adapted from the Spreadsheet::ParseExcel documentation, showing how to iterate through all sheets and to access just one sheet:

use strict; use warnings; use Spreadsheet::ParseExcel; my $parser = Spreadsheet::ParseExcel->new(); my $workbook = $parser->parse('Book1.xls'); if ( !defined $workbook ) { die $parser->error(), ".\n"; } # Iterate through all worksheets, show value at A1 for my $worksheet ( $workbook->worksheets() ) { next unless my $cell = $worksheet->get_cell( 0, 0 ); # row, col print 'Worksheet: ' . $worksheet->get_name() . '; A1: ' . $cell->value() . "\n"; } print "\n"; # Get only one sheet, show value at A1 if ( my $worksheet = $workbook->worksheet('Sheet5') ) { # Can be in +dex 0-4, in this example if ( my $cell = $worksheet->get_cell( 0, 0 ) ) { # row, col print 'Worksheet: ' . $worksheet->get_name() . '; A1: ' . $cell->value() . "\n"; } }

Output:

Worksheet: Sheet1; A1: 42 Worksheet: Sheet2; A1: 21 Worksheet: Sheet3; A1: 17 Worksheet: Sheet4; A1: 58 Worksheet: Sheet5; A1: 100 Worksheet: Sheet5; A1: 100

Hope this helps!


Comment on Re: parse only one sheet at time In Spreadsheet::ParseExcel
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (3)
As of 2014-08-31 03:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (294 votes), past polls