[英]How to replace blank cell values with a word in excel Java POI
如何使用Java Apache POI在Excel文件中用單詞“ Not Available”填充所有空白單元格?
我使用了以下代碼,但是它僅適用於某些列,只是我不知道是什么原因? 確切地說是從第1000行開始。 (我有一個很大的Excel文檔)
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");
}
}
}
沒有您的代碼,很難弄清楚。 樣例代碼
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");
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.