Can somebody please explain about the Missing cell policy
of Apache POI
? What are exactly missing cells ? I didn't find the Apache POI
docs link to be self-explanatory on what exactly are missing cells.
Did you read the Apache POI Excel Busy Developer's Guide?
In some cases, when iterating, you need full control over how missing or blank rows and cells are treated, and you need to ensure you visit every cell and not just those defined in the file. (The CellIterator will only return the cells defined in the file, which is largely those with values or stylings, but it depends on Excel).
In cases such as these, you should fetch the first and last column information for a row, then call getCell(int, MissingCellPolicy) to fetch the cell. Use a MissingCellPolicy to control how blank or null cells are handled.
If you're iterating over columns in a row, some cells that are blank may not even exist, which may causing unsuspecting code to throw a NullPointerException
. A MissingCellPolicy
, when passed to getCell
, guides and simplifies code that tells Apache POI how to handle these kinds of cells.
Cell
returned doesn't exist, instead of returning null
, create a new Cell
with a cell type of "blank". This can help avoid NullPointerException
s conveniently.null
. This can allow you ignore blank cells that do exist easily.null
for cells that don't really exist and return the blank Cell
if it exists but its cell type is blank. This is the behavior of the getCell
overload that doesn't take a MissingCellPolicy
.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With