Spreadsheet::ParseXLSX 和空白单元格

Spreadsheet::ParseXLSX and blank cells

我正在尝试使用 Spreadsheet::ParseXLSX 解析 XLSX 文件(逐行获取每个单元格的值)。在遍历每一行的循环中,我尝试使用以下代码提取值:

$thisCell = $worksheet->get_cell($currentRow, $currentCol)->value();

还有:

$thisCell = $worksheet->get_cell($currentRow, $currentCol)->unformatted();

但是,如果遇到空单元格,脚本总是会中断。我得到的错误方法是"Can't call method [value|unformatted] on an undefined value..."

尝试预测或处理我尝试过的空单元格:

我真的被困在这个问题上了,我确信这是我正在搞砸的基本问题。任何帮助将不胜感激。

my $cell = $worksheet->get_cell($currentRow, $currentCol);

my $value = $cell ? $cell->value : undef;