By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,708 Members | 2,055 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,708 IT Pros & Developers. It's quick & easy.

How to read Excel data into a hash

P: 2
I'm trying to read excel data into a hash. Here's my code so far.
Expand|Select|Wrap|Line Numbers
  1. foreach my $row (2..3)
  2. {
  3.  foreach my $col (1..2)
  4.  { 
  5.  # skip empty cells
  6.   next unless defined $Sheet->Cells($row)->{'Value'};
  7.  
  8.  # store the values of each cell in the hash  
  9.   $store[$row][$col] = $Sheet->Cells($row, $col)->{'Value'};
  10.  }
  11. }
  12.  
May 20 '10 #1
Share this Question
Share on Google+
1 Reply


P: 2
or this

Expand|Select|Wrap|Line Numbers
  1. foreach my $row (2..3)
  2. {
  3.  foreach my $col (1..2)
  4.  { 
  5.  # skip empty cells
  6.   next unless defined $Sheet->Cells($row)->{'Value'};
  7.  
  8.  # store the values of each cell in the hash  
  9.   $store[$row] = $Sheet->Cells($row)->{'Value'};
  10.   $store[$col] = $Sheet->Cells($col)->{'Value'};
  11.  }
  12. }
  13.  
May 20 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.