0
如何從我的Excel xlsx表單中獲取特定的單元格值? 例如我想從小區6和8 得到所有值這是我做了什麼 - 我得到的整排Java - Apache POI讀取特定單元格中的XSSF文件
public void readExcelFile() {
try {
InputStream ExcelFileToRead = new FileInputStream("D:\\20161111_Gesamtliste_aller_Anschreiben.xlsx");
XSSFWorkbook wb = new XSSFWorkbook(ExcelFileToRead);
XSSFSheet sheet = wb.getSheetAt(0);
XSSFRow row;
XSSFCell cell;
Iterator rows = sheet.rowIterator();
int read = 0;
while (rows.hasNext()) {
read++;
row = (XSSFRow) rows.next();
Iterator cells = row.cellIterator();
while (cells.hasNext()) {
cell = (XSSFCell) cells.next();
if (cell.getCellType() == XSSFCell.CELL_TYPE_STRING) {
System.out.print(cell.getStringCellValue() + " ");
} else if (cell.getCellType() == XSSFCell.CELL_TYPE_NUMERIC) {
System.out.print(cell.getNumericCellValue() + " ");
} else {
}
}
System.out.println();
}
System.out.println(read);
} catch (Exception ex) {
ex.printStackTrace();
}
}
請問[this](https://stackoverflow.com/a/12857969/6565719)有幫助嗎? –