我正在尝试阅读.xlsx
Excel文件,但我得到一个例外:
从excel获取数据时出错无效的标头签名;读 1688935826934608,预计-2226271756974174256
我错过了什么?
我的代码是
FileInputStream fileInputStream;
try {
fileInputStream = new FileInputStream(filePath + "\\"
+ "uploadAreaExcel.xlsx");
HSSFWorkbook workbook;
workbook = new HSSFWorkbook(fileInputStream);
HSSFSheet worksheet = workbook.getSheet("Sheet1");
System.out.println("Total Count :"
+ Integer.toString(worksheet.getLastRowNum()));
for(int i=1;i<worksheet.getLastRowNum();i++){
HSSFRow row1 = worksheet.getRow(i);
HSSFCell cellA1 = row1.getCell((short) 0);
System.out.println(cellA1.getStringCellValue());
HSSFCell cellB1 = row1.getCell((short) 1);
System.out.println(cellB1.getStringCellValue());
}
} catch (Exception e) {
System.out.println("Error in getting data from excel "+e.getMessage());
}