【发布时间】:2015-10-12 10:05:49
【问题描述】:
我尝试使用 jxl jar 读取旧格式的 Excel 表格,它工作正常,但在 255 行之后它会抛出错误:
java.lang.ArrayIndexOutOfBoundsException: 255
我无法使用 Poi jar 阅读,因为它是旧格式,非常感谢任何帮助!
下面是java代码sn-p:
public HashMap<String, Float> readAllRowsOnePoint(String path, String sheetname) throws BiffException, IOException {
System.out.println("Path download" + path);
FileInputStream fs = new FileInputStream(path);
Workbook wb = Workbook.getWorkbook(fs);
Sheet sheet = wb.getSheet(sheetname);
// To get the number of rows present in sheet
int totalNoOfRows = 500;
System.out.println("The rows count is " + totalNoOfRows);
HashMap<String, Float> map = new HashMap<>();
for (int row = 2; row < totalNoOfRows; row++) {
try {
Cell dateCell = null;
Cell psidCell = null;
Cell nameCell = null;
Cell quantityCell = null;
Cell billingCell = null;
try {
dateCell = sheet.getCell(0, row);
psidCell = sheet.getCell(1, row);
nameCell = sheet.getCell(2, row);
quantityCell = sheet.getCell(8, row);
billingCell = sheet.getCell(10, row);
} catch(Exception e){
// e.printStackTrace();
}
String date = dateCell.getContents().trim();
String psid = psidCell.getContents().trim();
String name = nameCell.getContents().trim();
String quantity = quantityCell.getContents().trim();
String billing = billingCell.getContents().trim();
System.out.println();
} catch(Exception e) {
System.out.println("Error in row " + row + " Exception " );
}
}
return map;
}
【问题讨论】:
-
你找到答案了吗?我很确定它可以处理大于 255 的行,因为我的开始像你的一样窒息(ArrayIndexOutOfBoundsException),但我的在 1315+
标签: java excel apache-poi