我想一次读取100行的大块excel文件。我这样做(伪代码)
readExcel(String tofile, int start, int end){
FileInputStream file = new FileInputStream(new File(toFile));
org.apache.poi.ss.usermodel.Workbook workbook = WorkbookFactory.create(file); // creating workbook
org.apache.poi.ss.usermodel.Sheet sheet = workbook.getSheetAt(0); // creating sheet
int rw = 0;
int cnt = 0;
for (rw = start; cnt < end; rw++) {
cnt++;
if (sheet.getRow(rw) != null) {
Row row = sheet.getRow(rw);
// Do Something
}
}
}
使用cnt = 100调用readExcel并更改变量&#39; start&#39;每次通话开始+ 100。这个实现是否正确? sheet.getRow()函数是否具有随机访问权限或顺序访问权限? 有没有更好的方法来获得所需的结果?