in reply to Re^7: Converting Excel to Hash
in thread Converting Excel to Hash
use Spreadsheet::ParseExcel; use Data::Dumper; $filename="Book2.xls"; $e=new Spreadsheet::ParseExcel; $eBook=$e->Parse($filename); $sheets = $eBook->{SheetCount}; ($eSheet, $sheetName); foreach $sheet (0 .. $sheets - 1) { $eSheet = $eBook->{Worksheet}[$sheet]; $sheetName = $eSheet->{Name}; print "Worksheet $sheet: $sheetName\n"; %set =(); %data =(); foreach $row( 1 .. $eSheet->{MaxRow} ) { if (defined ($eSheet->{Cells}[$row][0] )) { $master_key=($eSheet->{Cells}[$row][0]->Value); $r=$row; } else { $master_key=$master_key; } foreach $col(1 .. $eSheet->{MaxCol}) { my $key=$eSheet->{Cells}[0][$col]->Value; if (defined $eSheet->{Cells}[$row][$col]) { $val=($eSheet->{Cells}[$row][$col]->Value); } else { $val=$eSheet->{Cells}[$r][$col]->Value; } $set{$key}=$val; } if ($row>0) { } push @{ $data{$master_key}}, \%set; } print Dumper \%data; }C:\perlpractice>c.pl Worksheet 0: Sheet1 $VAR1 = { '1' => [ { + 'clz' => 'iir', + ' degree' => 'b.tch 'name' => 'ravi' }, . + $VAR1->{'1'}[0] ], '2' => [ $VAR1->{'1'}[0] ] };
Iam getting output in the above fashion.Please help .I want to store the data in a Hash
.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^9: Converting Excel to Hash
by hippo (Archbishop) on Jan 04, 2017 at 11:34 UTC | |
by ravi179 (Novice) on Jan 04, 2017 at 11:59 UTC | |
by Corion (Patriarch) on Jan 04, 2017 at 12:03 UTC | |
by ravi179 (Novice) on Jan 04, 2017 at 12:19 UTC | |
by poj (Abbot) on Jan 04, 2017 at 13:25 UTC | |
by poj (Abbot) on Jan 04, 2017 at 12:40 UTC | |
by Corion (Patriarch) on Jan 04, 2017 at 12:27 UTC | |
| |
|
Re^9: Converting Excel to Hash
by poj (Abbot) on Jan 04, 2017 at 11:59 UTC | |
by ravi179 (Novice) on Jan 05, 2017 at 04:52 UTC | |
by poj (Abbot) on Jan 05, 2017 at 08:23 UTC | |
by ravi179 (Novice) on Jan 05, 2017 at 08:48 UTC |