Spreadsheet :: ParseExcel $ cell-> value()返回undef

时间:2015-06-03 10:42:32

标签: excel perl undef

我是perl的新手,并且遇到电子表格excel解析器模块的问题。

当我在其自己的行上使用$ cell-&gt; value()时,似乎没有问题,但是当我尝试使用它将值插入数组时,它返回undef,代码显示如下:< / p>

for my $row ($row_min .. $row_max) {
    my @line;
        for my $col ( $col_min .. $col_max) {
                my $cell = $worksheet->get_cell( $row, $col );
                $value = $cell->value;
                push @line, $value if defined($cell);
                print $cell->value;
                print Dumper $line;
                }

         }
}

这里打印$ cell-&gt;值;返回单元格的内容但打印Dumper $ line;返回undef

1 个答案:

答案 0 :(得分:2)

您必须推$cell->value而不是$value

push @line, $cell->value if defined($cell);

您应该在程序开头添加use strict,以便在这种情况下收到错误消息。

相关问题