How can I fill all the blank cells in an excel file with the word "Not Available" using Java Apache POI?
I have used the following code but it only works for some of the columns only I can't figure out what is the reason? To be exact from the 1000nd row it works. (I have a very large excel document)
XSSFRow r1;
for(Row r : firstSheet)
{
r1=(XSSFRow) r;
for (Cell cell : r) {
if(cell == null || cell.getCellType() == Cell.CELL_TYPE_BLANK)
{
XSSFCell cell2 = r1.createCell(cell.getColumnIndex());
cell.setCellValue("Not Available");
}
}
}
Without your code, its hard to figure out. Sample code
CellReference cr = new CellReference(entry.getKey());
int r = cr.getRow();
int c = cr.getCol();
Row row = sheet.getRow(r);
if (row == null)
row = sheet.createRow(r);
Cell cell = row.getCell(c, Row.CREATE_NULL_AS_BLANK);
cell.setCellValue("Not Available");