Я использую Apache POI для чтения документа Excel. Я хочу получить значение ячейки из следующей строки, если текущая пуста. Например, получить из первой строки все непустые значения ячеек, а для пустых ячеек: перейти к следующей строке и получить значение. Это код, который я использую для чтения документа Excel
//every sheet has rows, iterate over them
Iterator<Row> rowIterator = sheet.iterator();
if (rowIterator.hasNext())
rowIterator.next();
while (rowIterator.hasNext())
{
String libelle="";
.....
//Get the row object
Row row = rowIterator.next();
//Every row has columns, get the column iterator and iterate over them
Iterator<Cell> cellIterator = row.cellIterator();
while (cellIterator.hasNext())
{
//Get the Cell object
Cell cell = cellIterator.next();
//check the cell type and process accordingly
//2nd column
switch(cell.getCellType()){
case Cell.CELL_TYPE_STRING:
......
if (row.getCell(5) == null)
{
System.out.println("Cell is Empty in Column:" );
} else if (row.getCell(5).getCellType() == HSSFCell.CELL_TYPE_STRING)
{
libelle= row.getCell(5).getStringCellValue().trim();
}
...