我正在尝试解析一个excel文件,其中我必须读取标题和数据Parallelly.I需要检查,而解析标题如果找到空白单元格,我必须立即跳过单元格然后选择下一个值,但这不能在另一个迭代中完成。我已经尝试但在我的代码中我在跳过的单元格中没有任何价值,
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
}
请有人帮我正确处理方法,提前致谢
答案 0 :(得分:1)
下面的代码可以帮到你。请检查。 if(cell == null || c.getCellType()== Cell.CELL_TYPE_BLANK){
}
答案 1 :(得分:0)
用这个检查
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
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 (value.equals("")){
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
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
}
}
String cellValue = excelManager.evalCell(currentCell);
String cellValueTotal = excelManager.evalCell(currentCellTotal);