poi读取Excel文件出现这样的错误
The supplied data appears to be in the Office 2007+ XML. You are calling the part of POI that deals with OLE2 Office Documents. You need to call a different part of POI to process this data (eg XSSF instead of HSSF)
原来写的是
InputStream in = new FileInputStream(file);
//获取文件
HSSFWorkbook workbook = new HSSFWorkbook(in);
//得到第一张表
HSSFSheet sheet = workbook.getSheetAt(0);
HSSFWorkbook 是用于2003的.xls文件读取
XSSFWorkbook是用于2007.xlsx文件读取
这两个是不一样的
所以在读取文件时先判断一下文件名