|Summary:||Cells that contain only comments are missing in XSSFRow|
|Component:||XSSF||Assignee:||POI Developers List <dev>|
Description Rick 2011-10-07 10:30:52 UTC
If I add a comment to an empty cell within Excel I can read this cell comment with XSSFSheet#getCellComment(int row, int column) but when I try to get the according cell from the Row object by #getCell(int cellnum) I do get null returned. I actually would expect a blank cell with the comment on it as return value.
Comment 1 Yegor Kozlov 2012-02-27 09:18:08 UTC
By default, Row#getCell returns what is physically stored in the workbook stream and in your case it is null. However, you can control what to do when getting missing or blank cells with Workbook.setMissingCellPolicy(MissingCellPolicy missingCellPolicy); there are three options: /** Missing cells are returned as null, Blank cells are returned as normal */ public static final MissingCellPolicy RETURN_NULL_AND_BLANK = new MissingCellPolicy(); /** Missing cells are returned as null, as are blank cells */ public static final MissingCellPolicy RETURN_BLANK_AS_NULL = new MissingCellPolicy(); /** A new, blank cell is created for missing cells. Blank cells are returned as normal */ public static final MissingCellPolicy CREATE_NULL_AS_BLANK = new MissingCellPolicy(); If you expect a blank cell then call workbook.setMissingCellPolicy(MissingCellPolicy.CREATE_NULL_AS_BLANK ); after constructing your workbook. Yegor