Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
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 drinking their drinks and smoking their pipes about the Monastery: (7)
As of 2015-07-31 01:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (274 votes), past polls