in reply to How to parse excel files having multiple tables with different number of elements?

This was a simple mistake. Look here:

for my $col(0..4) { my $key=$worksheet->get_cell(0,$col)->value; my $cell=$worksheet->get_cell($row,$col); next unless $cell; my $value=$cell->value();

The blank cells in Garry's row are causing the error, meaning that your 'next unless $cell' statement is not skipping the empty cells. Maybe try:

for my $col(0..4) { my $key=$worksheet->get_cell(0,$col)->value; my $cell=$worksheet->get_cell($row,$col); unless($cell){ # Null value } else{ my $value=$cell->value(); ... }

I tested this and it worked for me.

  • Comment on Re: How to parse excel files having multiple tables with different number of elements?
  • Select or Download Code