try {
String fileType = filepath.substring(filepath.lastIndexOf(".")+1);
Workbook workbook = null;
InputStream is = new FileInputStream(filepath);
if (fileType.equalsIgnoreCase("xlsx")) {
workbook = new XSSFWorkbook(filepath);
}else{
workbook = new HSSFWorkbook(is);
}
这样试试