如何在使用 POI 迭代 excel 文件时跳过空白单元格值并选取下一个单元格



我正在尝试解析一个 excel 文件,我必须在其中并行读取标题和数据.我需要检查,在解析标题时如果找到空白单元格,我必须立即跳过单元格并选取下一个值,但这无法在另一个迭代中完成。在这里我已经尝试过,但在我的代码中,我在跳过的单元格中没有得到任何值,

while (cellIterator.hasNext() && cellIteratorTotal.hasNext()) {
cellCount++;
Cell currentCell = cellIterator.next();
Cell currentCellTotal = cellIteratorTotal.next();
currentRow =  sheet.getRow(currentRowTotal.getRowNum() + 1); // here i am trying to hold the current row value 
String cellValue = excelManager.evalCell(currentCell);
String cellValueTotal = excelManager.evalCell(currentCellTotal);
if(currentRow!=null) {
String value = currentRow.getCell(currentCellTotal.getColumnIndex(), Row.CREATE_NULL_AS_BLANK).getStringCellValue(); //  here i am trying to get the next cell value 
}

任何人都可以帮助我采取正确的方法,提前谢谢

下面的代码可以帮助你。请检查。 if (cell == null || c.getCellType(( == Cell.CELL_TYPE_BLANK( {

}

最新更新