且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在读取excel文件时,如何识别单元格为空或null或为空

更新时间:2023-11-29 19:03:52

不确定为什么要手动识别单元格类型,但如果要将案例空或空白视为单个案例,则可以使用其他版本的Row.getCell,它采用第二个参数指定缺少单元格策略

Not sure why you want to identify manually the cell type but if you want to treat cases "null" or "blank" as a single case you can use the other version of Row.getCell, which takes a second argument that specifies the missing cell policy.

所以:

 xcell= xrow.getCell(cell);

将成为:

 xcell = xrow.getCell(cell, Row.RETURN_NULL_AS_BLANK);

所以在任何情况下,单元格都有一个值或为空,但从不为空。

so in any cases the cell has a value or is blank , but never null.