Ask Your Question
4

Is it possible to verify if a cell value is either empty or null using Apache POI?

asked 2021-08-21 11:00:00 +0000

woof gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2023-04-10 19:00:00 +0000

nofretete gravatar image

Yes, it is possible to verify if a cell value is either empty or null using Apache POI.

Here is an example code snippet:

Cell cell = row.getCell(columnIndex);
if(cell == null || cell.getCellType() == CellType.BLANK){
    // cell is either null or empty
}

In this code, we first check if the cell reference is null. If it is null, then the cell is considered empty. We also check if the cell type is BLANK. If the cell type is blank, then the cell is also considered empty.

Note that if a cell contains a formula that evaluates to an empty string, it will still be considered non-empty. In that case, you can use the cell.getStringCellValue() method and check if the returned value is an empty string.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2021-08-21 11:00:00 +0000

Seen: 21 times

Last updated: Apr 10 '23