无法迭代XLS spreadsheet
中行的全部范围。代码{sheet.getPhysicalNumberOfRows}
返回33492,没有引发异常,但是大约有43,000行?。
如果我手动提供正确的号码,则循环执行而不会产生投诉。
答案必须很简单,但我找不到任何地方。有人可以帮忙吗?
try {
POIFSFileSystem fs = new POIFSFileSystem(new
FileInputStream(fileLocation));
HSSFWorkbook wb = new HSSFWorkbook(fs);
HSSFSheet sheet = wb.getSheetAt(0);
HSSFRow row;
HSSFCell cell;
int rows; // No of rows
rows = sheet.getPhysicalNumberOfRows(); //Gets => 33494
int cols = 1; // No of columns
int tmp = 0;
for (int r = 0; r < rows; r++) {
row = sheet.getRow(r);
if (row != null) {
cell = row.getCell(0);
if (cell != null) {
System.out.println("Line number: " + r " = " + cell);
}
}
}
} catch(Exception ioe) {
ioe.printStackTrace();
}