InputStream fis = file.getInputStream(); Workbook wookbook = null; String filename = file.getOriginalFilename(); filename = filename.trim(); filename = filename.substring(0, filename.lastIndexOf(".")); String suffix=file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));//后缀名 if(suffix.equals(".xls")){ wookbook = new HSSFWorkbook(fis); }else if(suffix.equals(".xlsx")){ wookbook = new XSSFWorkbook(fis); }else { throw new RuntimeException("不支持的格式:"+suffix); }
标签:fis,suffix,excel,filename,getOriginalFilename,导入,file,wookbook,格式 From: https://www.cnblogs.com/axu92312/p/17493071.html