excel导入时,对两种版本格式的支持

  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);
            }

 

posted @ 2023-06-20 11:02  阿旭92312  阅读(13)  评论(0编辑  收藏  举报