我想从 Java 中的第 n 行 excel 表之后的特定行中读取。我不想检查单元格是否具有价值。我只想跳过一些起始行说 n 并从第 n+1 行开始读取。
我将如何实现这一目标?
FileInputStream fileInputStream = new FileInputStream(fileName);
POIFSFileSystem fsFileSystem = new POIFSFileSystem(fileInputStream);
HSSFWorkbook workBook = new HSSFWorkbook(fsFileSystem);
HSSFSheet hssfSheet = workBook.getSheetAt(0);
Iterator<Row> rowIterator = hssfSheet.rowIterator();
boolean headerRow = true;
while (rowIterator.hasNext()) {
if (headerRow == false) {
HSSFRow hssfRow = (HSSFRow) rowIterator.next()
Iterator<Cell> iterator = hssfRow.cellIterator();
List cellTempList = new ArrayList();
while (iterator.hasNext()) {
HSSFCell hssfCell = (HSSFCell) iterator.next();
if(hssfCell.getCellType() == hssfCell.CELL_TYPE_NUMERIC)
{DecimalFormat df = new DecimalFormat("#");
String cellValue=df.format(hssfCell.getNumericCellValue());
cellTempList.add(cellValue.toString());
}
else if(hssfCell.getCellType() == hssfCell.CELL_TYPE_STRING)
{ cellTempList.add(hssfCell.toString());
}
}
cellDataList.add(cellTempList);