美文网首页
java导入excel,错误返回消息生成txt文档,并指定错误消

java导入excel,错误返回消息生成txt文档,并指定错误消

作者: 简陌刀丶阿吉 | 来源:发表于2018-09-20 10:48 被阅读0次
1、整理一下导入excel,最终实现结果如下:

由于没有git账户,所以代码都整理到了这篇文章中,太长,取自己需要即可。


导入按钮
导入按钮打开的dialog
上传文件后返回的错误消息
导出成功存储提示
2、话不多说,上代码:

工程结构: 本示例使用的是Springboot,用的是SpringMVC架构。工程结构就不截图了。

pom依赖:

<!-- POI依赖 -->
   <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi</artifactId>
        <version>3.14</version>
    </dependency>
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-examples</artifactId>
        <version>3.14</version>
    </dependency>
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-excelant</artifactId>
        <version>3.14</version>
    </dependency>
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-ooxml</artifactId>
        <version>3.14</version>
    </dependency>
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-scratchpad</artifactId>
        <version>3.14</version>
    </dependency>

html代码:
导入按钮代码:

<a id="import_btu" href="javascript:;" class="easyui-linkbutton zd-btn" data-options="toggle:true,group:'g1'" style="width:65px;height:24px;">导入</a>

导入按钮打开的dialog:

  <div id="reportDialog" class="easyui-dialog" title="报送文件上传" style="width:500px;height:100px;" data-options="closable:true,modal:true,closed:true">
    <input class="easyui-filebox" id="upfile" data-options="prompt: '请选择.xls文件',buttonText:'选择文件'" name="upfile" style="width:60%;height:34px"/>
    <a id="reportUploadButton" class="easyui-linkbutton" style="width:80px; height:34px;" data-options="toggle:true,group:'g1'">上传</a>
  </div>

js代码:
导入按钮代码:

/**
 * 导入
 * @returns
 */
$("#import_btu").bind('click', function(){
    // 重新渲染filebox
    $("input[name=upfile]").val();
    $("#upfile").filebox({
            buttonText: "选择文件"
    });
    // 选择文件按钮右边显示
    $("#reportDialog span a:first").css("marginLeft",'80%');
    // 打开上传
    $("#reportDialog").dialog('open');
});

上传按钮代码:代码中需要注意,其中有/importLedExcel请求,success下相关代码中是导出文本的代码逻辑。

/**
 * 导入按钮
 * 
 * @returns
 */
$("#reportUploadButton").bind("click", function() {
// 判断选择的文件是否是.xls文件
var file = $("#upfile").filebox("getValue");
var suffix = file.substring(file.lastIndexOf('.') + 1);
// 校验上传格式
if (file == '' || file == null) {
    $.messager.alert("提示", "请选择上传文件", "warning");
    return false;
} else if (suffix != "xls") {
    $.messager.alert("提示", "请选择模版下载的excel文件", "warning");
    return false;
} else {
    var formData = new FormData();
    formData.append("file", $("input[name=upfile]")[0].files[0]);
    $.ajax({
        url : '/importLedExcel',
        type : 'POST',
        async : false,
        data : formData,
        // 告诉jQuery不要去处理发送的数据
        processData : false,
        // 告诉jQuery不要去设置Content-Type请求头
        contentType : false,
        success : function(data) {
            $("#reportDialog").dialog('close');

            // 根据状态判断显示信息
            if (data.status == 0) {
                if (data.filePath != null || data.filePath != undefined) {
                     $.messager.confirm('确认对话框','导入失败,是否查看错误详情?',function (r) {
                          if (r){  
                                var form = $("<form></form>")
                                form.attr('action','/downErrorFile')
                                form.attr('method','post')
                                form.appendTo("body")
                                form.css('display','none')
                                form.submit()
                            }
                     });
                } else {
                    $.messager.alert("操作提示", data.message, "warning");
                }
                return false;
            } else if (data.status == 1) {
                $.messager.alert("操作提示",data.message, "info");
            }
        }
    });
}
});

controller代码:下列代码包括三种,一个是工具类,用来导入模版,另一种是导入代码和校验代码,第三种是写入错误消息并导出txt文档代码。
注意:代码中有部分调用service层的代码,去掉就可以,如果需要可以更换成自己的代码进行处理。
下述代码如有需要可直接复制使用,错误内容自行更改。

导入代码和校验代码:

/**
 * 
 * 导入电子站牌
 * 
 * @param request
 * @param file
 *            导入的文件对象
 * @returntish 提示消息
 */
@PostMapping(value = ConstantUtil.IMPORTLEDEXCEL)
public Map<String, Object> importLedExcel(HttpServletRequest request, @RequestParam(ConstantUtil.FILE) MultipartFile file, HttpSession session) {
    Map<String, Object> resMap = new HashMap<>();
    // 存放解析完的excel数据
    List<Map<String, Object>> importList = new ArrayList<Map<String, Object>>();
    // 存放解析完的标题数据
    Map<String, Object> titleStringMap = new HashMap<String, Object>();
    String title = null;
    // 声明并初始化Excel文件中列名的集合
    List<String> colList = new ArrayList<String>();
    // 以下列名顺序需要与Excel文件中列名顺序匹配
    String[] titleArray = ConstantUtil.ANY_CONSTANT_IMPORT_TITLEVAR.split(ConstantUtil.DOUHAO);
    colList = Arrays.asList(titleArray);
    // 判断导入的文件是否为空
    if (null != file) {
        // 验证导入文件标题是否与导入模板匹配
        try {
            titleStringMap = ImportExcel2007Util.getImportExcelTitle(ConstantUtil.ANY_CONSTANT_IMPORT_DATAROW, file.getInputStream(),
                    ConstantUtil.ANY_CONSTANT_IMPORT_COUNTCOL, null);
            if (null != titleStringMap) {
                // 判断是否有错误消息写入Map中
                if (null == titleStringMap.get(ConstantUtil.ERRORMSG)) {
                    // 获取标题
                    title = String.valueOf(titleStringMap.get(ConstantUtil.TITLESTRING));
                    // 判断导入标题是否与模板标题匹配
                    if (ConstantUtil.ANY_CONSTANT_IMPORT_TITLE.equals(title)) {
                        // 将导入的Excel文件内容存储到List中
                        importList = ImportExcel2007Util.doImmportExcel(ConstantUtil.ANY_CONSTANT_IMPORT_DATAROW, file.getInputStream(),
                                ConstantUtil.ANY_CONSTANT_IMPORT_COUNTCOL, colList);
                        if (!importList.isEmpty()) {
                            // 调用验证方法
                            resMap = validateXcjh(importList);
                            // 通过校验,执行保存操作
                            if (resMap.get(ConstantUtil.STATUS).equals(ConstantUtil.STATUS_ONE)) {
                                @SuppressWarnings("unchecked")
                                List<Map<String, Object>> paramList = (List<Map<String, Object>>) resMap.get("data");
                                for (Map<String, Object> paramMap : paramList) {
                                    // 验证通过后进行保存操作// 获取用户信息
                                    JtlSysUser jtlSysUser = WebDataUtil.getSysUserInfo(session);
                                    // 获取用户信息
                                    String userName = jtlSysUser.getUserName();
                                    paramMap.put("xgr", userName);
                                    paramMap.put("cjr", userName);
                                    paramMap.put("bz", "无");
                                    List<Map<String, Object>> delList = new ArrayList<>();
                                    List<Map<String, Object>> updateList = new ArrayList<>(); 
                                    paramMap.put("addList", paramMap.get("stationString"));
                                    paramMap.put("delList", delList);
                                    paramMap.put("updateList", updateList);
                                    paramMap.remove("stationString");
                                    // 执行数据存储
                                    int flag = ledLedManageService.saveLedList(paramMap);
                                    int flag = 1;
                                    if (flag == 1) {
                                        resMap.put(ConstantUtil.STATUS, ConstantUtil.STATUS_ONE);
                                        resMap.put(ConstantUtil.MSG, ConstantUtil.COMMON_SUCCESS);
                                    } else {
                                        resMap.put(ConstantUtil.STATUS, ConstantUtil.STATUS_ZERO);
                                        resMap.put(ConstantUtil.MSG, ConstantUtil.COMMON_FAILURE);
                                    }
                                }
                            }
                        }
                    } else {
                        resMap.put(ConstantUtil.STATUS, ConstantUtil.STATUS_ZERO);
                        resMap.put(ConstantUtil.MSG, ConstantUtil.IMPORTEXCEL_TITLE_ERROR);
                    }
                } else {
                    resMap.put(ConstantUtil.STATUS, ConstantUtil.STATUS_ZERO);
                    resMap.put(ConstantUtil.MSG, titleStringMap.get(ConstantUtil.ERRORMSG));
                }
            } else {
                resMap.put(ConstantUtil.STATUS, ConstantUtil.STATUS_ZERO);
                resMap.put(ConstantUtil.MSG, ConstantUtil.IMPORTEXCEL_TITLE_NULL);
            }
        } catch (Exception e) {
            e.printStackTrace();
            resMap.put(ConstantUtil.STATUS, ConstantUtil.STATUS_ZERO);
            resMap.put(ConstantUtil.MSG, ConstantUtil.IMPORTEXCEL_FAILE);
        }
    }
    return resMap;
}

/**
 * 
 * 校验导入行车计划明细的方法
 * 
 * @param paramList
 *            导入的站牌信息
 * @return 返回status状态
 * @return message消息
 * @return datas数据
 * @throws Exception
 */
public Map<String, Object> validateXcjh(List<Map<String, Object>> paramList) throws Exception {
    // 用来提示用户第几行有问题
    int i = 0;
    // IP正则表达式
    String reg = ConstantUtil.IPREG;
    Pattern pattern = Pattern.compile(reg);
    Map<String, Object> resMap = new HashMap<>();
    // 存放错误提示消息
    String errorMsg = ConstantUtil.NULL_STRING;
    // 校验数据
    for (Map<String, Object> rowMap : paramList) {
        rowMap.put("ledid", "");
        // 第i行
        i++;
        // 获取sheet页名称
        String sheetName = String.valueOf(rowMap.get(ConstantUtil.SHEETNAME));
        // 站牌名称
        String ledmc = String.valueOf(rowMap.get("ledmc"));
        // 站牌编号
        String ledbh = String.valueOf(rowMap.get("ledbh"));
        // 经度
        String jd = String.valueOf(rowMap.get("jd"));
        // 纬度
        String wd = String.valueOf(rowMap.get("wd"));
        // 方向
        String ledfx = String.valueOf(rowMap.get("ledfx"));
        // 网关
        String wg = String.valueOf(rowMap.get("wg"));
        // 本地设备IP地址
        String bdsbipdz = String.valueOf(rowMap.get("bdsbipdz"));
        // 子网掩码
        String zwym = String.valueOf(rowMap.get("zwym"));
        // 关联站点列表
        String stationString = String.valueOf(rowMap.get("stationString"));
        // 校验电子站牌名称
        if (StringConvertUtils.isEmpty(ledmc)) {
            errorMsg = errorMsg + sheetName + ConstantUtil.MESSAGE_DE_DI + i + "行,站牌名称不能为空;" + ConstantUtil.HUANHANG;
        } else if (ledmc.length() > 10) {
            errorMsg = errorMsg + sheetName + ConstantUtil.MESSAGE_DE_DI + i + "行,站牌名称不能超过13位;" + ConstantUtil.HUANHANG;
        }
        Map<String, Object> valMap = new HashMap<>();
        valMap.put("tag", "1");
        valMap.put("ledmc", ledmc);
        // 校验电子站牌名称是否重复
        List<Map<String, Object>> ledmcList = ledLedManageService.validateLedMcAndLecBh(valMap);
        if (ledmcList != null && ledmcList.size() > 0) {
            errorMsg = errorMsg + sheetName + ConstantUtil.MESSAGE_DE_DI + i + "行,站牌名称已存在,不能使用;" + ConstantUtil.HUANHANG;
        }
        // 校验电子站牌编号
        if (StringConvertUtils.isEmpty(ledbh)) {
            errorMsg = errorMsg + sheetName + ConstantUtil.MESSAGE_DE_DI + i + "行,站牌编号不能为空;" + ConstantUtil.HUANHANG;
        } else if (ledmc.length() > 40) {
            errorMsg = errorMsg + sheetName + ConstantUtil.MESSAGE_DE_DI + i + "行,站牌编号不能超过40位;" + ConstantUtil.HUANHANG;
        }
        valMap.clear();
        valMap.put("tag", "1");
        valMap.put("ledmc", ledbh);
        // 校验电子站牌名称是否重复
        List<Map<String, Object>> ledbhList = ledLedManageService.validateLedMcAndLecBh(valMap);
        if (ledbhList != null && ledbhList.size() > 0) {
            errorMsg = errorMsg + sheetName + ConstantUtil.MESSAGE_DE_DI + i + "行,站牌编号已存在,不能使用;" + ConstantUtil.HUANHANG;
        }
        int x = 0;
        // 校验站牌名称是否在文档中重复
        for (Map<String, Object> valLedMcMap : paramList) {
            x++;
            if (valLedMcMap.get("ledmc").equals(ledmc) && x != i) {
                errorMsg = errorMsg + sheetName + ConstantUtil.MESSAGE_DE_DI + i + "行,站牌名称导入重复,不能使用;" + ConstantUtil.HUANHANG;
            }
        }
        int y = 0;
        // 校验站牌名称是否在文档中重复
        for (Map<String, Object> valLedbhMap : paramList) {
            y++;
            if (valLedbhMap.get("ledbh").equals(ledbh) && y != i) {
                errorMsg = errorMsg + sheetName + ConstantUtil.MESSAGE_DE_DI + i + "行,站牌编号导入重复,不能使用;" + ConstantUtil.HUANHANG;
            }
        }
        // 校验经度
        if (StringConvertUtils.isEmpty(jd)) {
            errorMsg = errorMsg + sheetName + ConstantUtil.MESSAGE_DE_DI + i + "行,经度不能为空;" + ConstantUtil.HUANHANG;
        } else if (jd.length() < 1 || jd.length() > 13) {
            errorMsg = errorMsg + sheetName + ConstantUtil.MESSAGE_DE_DI + i + "行,经度不正确,请输入1-13位数据;" + ConstantUtil.HUANHANG;
        }
        // 校验纬度
        if (StringConvertUtils.isEmpty(wd)) {
            errorMsg = errorMsg + sheetName + ConstantUtil.MESSAGE_DE_DI + i + "行,经度不能为空;" + ConstantUtil.HUANHANG;
        } else if (wd.length() < 1 || wd.length() > 13) {
            errorMsg = errorMsg + sheetName + ConstantUtil.MESSAGE_DE_DI + i + "行,经度不正确,请输入1-13位数据;" + ConstantUtil.HUANHANG;
        }
        // 校验方向
        if (StringConvertUtils.isEmpty(ledfx)) {
            errorMsg = errorMsg + sheetName + ConstantUtil.MESSAGE_DE_DI + i + "行,方向不能为空;" + ConstantUtil.HUANHANG;
        } else if (!ledfx.equals("上行") && !ledfx.equals("下行")) {
            errorMsg = errorMsg + sheetName + ConstantUtil.MESSAGE_DE_DI + i + "行,方向不是上行或下行,不允许添加!;" + ConstantUtil.HUANHANG;
        } else if (ledfx.equals("上行")) {
            rowMap.put("ledfx", "0");
        } else if (ledfx.equals("下行")) {
            rowMap.put("ledfx", "1");
        }
        Map<String, Object> csmap = new HashMap<>();
        csmap.put("mbmc", rowMap.get("csmbmc"));
        csmap.put("tag", "1");
        // 根据参数模版名称查询参数模版ID
        List<LedCsszb> ledcsszb = ledcsszbmanageservice.selectLedCsszbByMbinfo(csmap);
        csmap.remove("mbmc");
        csmap.remove("tag");
        // 校验是否存在参数模版名称
        if (ledcsszb == null || ledcsszb.isEmpty()) {
            errorMsg = errorMsg + sheetName + ConstantUtil.MESSAGE_DE_DI + i + "行,参数模版名称不存在;" + ConstantUtil.HUANHANG;
        } else {
            for (LedCsszb cs : ledcsszb) {
                rowMap.put("csmbid", cs.getMbid());
            }
        }
        // 校验网关
        Matcher wgm = pattern.matcher(wg);
        if (StringConvertUtils.isEmpty(wg)) {
            errorMsg = errorMsg + sheetName + ConstantUtil.MESSAGE_DE_DI + i + "行,网关不能为空;" + ConstantUtil.HUANHANG;
        } else if (!wgm.find()) {
            errorMsg = errorMsg + sheetName + ConstantUtil.MESSAGE_DE_DI + i + "行,网关不正确;" + ConstantUtil.HUANHANG;
        }
        // 校验本地设备IP地址
        Matcher bdsbipdzm = pattern.matcher(bdsbipdz);
        if (StringConvertUtils.isEmpty(bdsbipdz)) {
            errorMsg = errorMsg + sheetName + ConstantUtil.MESSAGE_DE_DI + i + "行,本地设备IP地址不能为空;" + ConstantUtil.HUANHANG;
        } else if (!bdsbipdzm.find()) {
            errorMsg = errorMsg + sheetName + ConstantUtil.MESSAGE_DE_DI + i + "行,本地设备IP地址不正确;" + ConstantUtil.HUANHANG;
        }
        // 校验子网掩码
        Matcher zwymm = pattern.matcher(zwym);
        if (StringConvertUtils.isEmpty(zwym)) {
            errorMsg = errorMsg + sheetName + ConstantUtil.MESSAGE_DE_DI + i + "行,子网掩码不能为空;" + ConstantUtil.HUANHANG;
        } else if (!zwymm.find()) {
            errorMsg = errorMsg + sheetName + ConstantUtil.MESSAGE_DE_DI + i + "行,子网掩码不正确;" + ConstantUtil.HUANHANG;
        }
        
        Map<String, Object> fqmap = new HashMap<>();
        fqmap.put("mbmc", rowMap.get("fqmbmc"));
        fqmap.put("tag", "1");
        // 根据分区模版名称查询分区模版ID
        List<Map<String, Object>> dataList =  ledtemplatemanageservice.selectLedTemplateByInfo(fqmap);
        fqmap.remove("tag");
        fqmap.remove("mbmc");
        // 校验是否存在分区模版名称
        if (dataList == null || dataList.isEmpty()) {
            errorMsg = errorMsg + sheetName + ConstantUtil.MESSAGE_DE_DI + i + "行,分区模版名称不存在;" + ConstantUtil.HUANHANG;
        } else {
            for (Map<String, Object> fqxx : dataList) {
                rowMap.put("fqmbid", fqxx.get("mbid"));
            }
        }
        stationString = stationString.replace(",", ",").replaceAll(";", ";");
        List<Map<String, Object>> stationList = new ArrayList<>();
        String str[] = stationString.split(";");
        List<String> list = new ArrayList<>();
        list = Arrays.asList(str);
        int j = 0;
        for (String s : list) {
            j++;
            int apache = StringUtils.countMatches(s, ",");
            if (apache != 2) {
                errorMsg = errorMsg + sheetName + ConstantUtil.MESSAGE_DE_DI + i + "行,关联站点列表缺少数据;" + ConstantUtil.HUANHANG;
            } else {
                
                Map<String, Object> stationTempMap = new HashMap<>();
                String valXlmc = s.substring(0, s.indexOf(","));
                String valFx = s.substring(s.indexOf(",") + 1, s.lastIndexOf(","));
                String valZdmc = s.substring(s.lastIndexOf(",") + 1);
                
                stationTempMap.put("valXlmc", valXlmc);
                List<Map<String, Object>> selectXlxx = commonService.selectXlxx(stationTempMap);
                // 校验线路是否存在
                if (selectXlxx == null || selectXlxx.isEmpty()) {
                    errorMsg = errorMsg + sheetName + ConstantUtil.MESSAGE_DE_DI + i + "行,关联站点列表线路不能为空;" + ConstantUtil.HUANHANG;
                } else {
                    // 取得线路编号
                    for (Map<String, Object> xlxx : selectXlxx) {
                        stationTempMap.put("xlbh", xlxx.get("xlmc"));
                    }
                }

                stationTempMap.put("fx", valFx);
                // 校验方向
                if (StringConvertUtils.isEmpty(valFx)) {
                    errorMsg = errorMsg + sheetName + ConstantUtil.MESSAGE_DE_DI + i + "行,关联站点列表方向不能为空;" + ConstantUtil.HUANHANG;
                } else if (!ledfx.equals("上行") && !ledfx.equals("下行")) {
                    errorMsg = errorMsg + sheetName + ConstantUtil.MESSAGE_DE_DI + i + "行,关联站点列表方向不是上行或下行,不允许添加!;" + ConstantUtil.HUANHANG;
                } else if (ledfx.equals("上行")) {
                    stationTempMap.put("fx", "0");
                } else if (ledfx.equals("下行")) {
                    stationTempMap.put("fx", "1");
                }
                
                stationTempMap.put("valZdmc", valZdmc);
                List<Map<String, Object>> selectZdxx = commonService.selectZdxx(stationTempMap);
                stationTempMap.remove("valXlmc");
                stationTempMap.remove("valZdmc");
                // 校验线路是否存在
                if (selectZdxx == null || selectZdxx.isEmpty()) {
                    errorMsg = errorMsg + sheetName + ConstantUtil.MESSAGE_DE_DI + i + "行,关联站点列表该线路下不存在该站点;" + ConstantUtil.HUANHANG;
                } else {
                    // 取得线路编号
                    for (Map<String, Object> zdxx : selectZdxx) {
                        stationTempMap.put("zdbh", zdxx.get("zdid"));
                        stationTempMap.put("dqzx", zdxx.get("zdxh"));
                        stationTempMap.put("zpxssx", j);
                    }
                }
                stationTempMap.put("xlmc", valXlmc);
                stationTempMap.put("zdmc", valZdmc);
                stationList.add(stationTempMap);
            }
            rowMap.put("stationString", stationList);
        }
        
    }
    
    // 判断是否有错误消息 返回导入的数据
    if (errorMsg.length() > 0) {
        resMap.put(ConstantUtil.STATUS, ConstantUtil.STATUS_ZERO);
        String name = ConstantUtil.IMPORT_ERROR_MESSAGE;
        // 写出错误消息
        creatTxtFile(name);
        writeTxtFile(errorMsg);
        resMap.put(ConstantUtil.MSG, errorMsg);
        resMap.put(ConstantUtil.FILEPATH, filenameTemp);
    } else {
        resMap.put(ConstantUtil.STATUS, ConstantUtil.STATUS_ONE);
        resMap.put(ConstantUtil.MSG, ConstantUtil.IMPORTEXCEL_SUCCESS);
        resMap.put(ConstantUtil.COMMON_DATA, paramList);
    }

    return resMap;
}

// 消息存储路径
private static String filenameTemp;

/**
 * 
 * 创建写入文本
 * @param name
 * @return
 * @throws IOException
 */
public static boolean creatTxtFile(String name) throws IOException {

    File path = new File(ResourceUtils.getURL("classpath:").getPath());
    if(!path.exists()) path = new File("");
    File upload =  new File(path.getAbsolutePath() + ConstantUtil.STATIC_FRONTEND_PROJECT_TEMPLATE);
    if(!upload.exists()) upload.mkdirs();
    boolean flag = false;
    filenameTemp = java.net.URLDecoder.decode(upload.getAbsolutePath().replaceAll("!", ConstantUtil.NULL_STRING), ConstantUtil.UTF_8) + File.separator+name + ConstantUtil.WORD_TXT;
    File filename = new File(filenameTemp);
    if (!filename.exists()) {
        filename.createNewFile();
        flag = true;
    }
    return flag;
}

  @RequestMapping(value = ConstantUtil.DOWNERROEFILE)
  public ResponseEntity<FileSystemResource> downErrorFile(HttpServletRequest request) throws Exception {
        File path = new File(ResourceUtils.getURL("classpath:").getPath());
        if(!path.exists()) path = new File("");
        File upload =  new File(path.getAbsolutePath() + ConstantUtil.STATIC_FRONTEND_PROJECT_TEMPLATE);
        if(!upload.exists()) upload.mkdirs();
        filenameTemp = java.net.URLDecoder.decode(upload.getAbsolutePath().replaceAll("!", ConstantUtil.NULL_STRING), ConstantUtil.UTF_8) + File.separator+ConstantUtil.IMPORT_ERROR_MESSAGE + ConstantUtil.WORD_TXT;
        File file = new File(filenameTemp);
        String userAgent = request.getHeader(ConstantUtil.USER_AGENT).toLowerCase();
        String fileName = ConstantUtil.ERRORFILENAME ;
        if (userAgent.contains(ConstantUtil.MSIE) || userAgent.contains(ConstantUtil.LIKE_GECKO)) {
            fileName = URLEncoder.encode(fileName, ConstantUtil.UTF_8);
        } else {
            fileName = new String(fileName.getBytes(ConstantUtil.UTF_8), ConstantUtil.ISO_8859_1);
        }
        if (file.exists()) {
            return export(file,fileName);
        }else {
            return null;
        }
        
    }
  
  public ResponseEntity<FileSystemResource> export(File file,String fileName) {
        if (file == null) {
            return null;
        }
        HttpHeaders headers = new HttpHeaders();
        headers.add("Cache-Control", "no-cache, no-store, must-revalidate");
        headers.add("Content-Disposition", "attachment; filename="+fileName+".txt");
        headers.add("Pragma", "no-cache");
        headers.add("Expires", "0");
        return ResponseEntity
                .ok()
                .headers(headers)
                .contentLength(file.length())
                .contentType(MediaType.parseMediaType("application/octet-stream"))
                .body(new FileSystemResource(file));
    }
/**
 * 
 * 向文本中写入内容
 * @param newStr
 * @return
 * @throws IOException
 */
public static boolean writeTxtFile(String newStr) throws IOException {
    // 先读取原有文件内容,然后进行写入操作
    boolean flag = false;
    String filein = newStr + ConstantUtil.HUANHANG;

    FileInputStream fis = null;
    InputStreamReader isr = null;
    BufferedReader br = null;

    FileOutputStream fos = null;
    PrintWriter pw = null;
    try {
        // 文件路径
        File file = new File(filenameTemp);
        // 将文件读入输入流
        fis = new FileInputStream(file);
        isr = new InputStreamReader(fis);
        br = new BufferedReader(isr);
        StringBuffer buf = new StringBuffer();

        buf.append(filein);

        fos = new FileOutputStream(file);
        pw = new PrintWriter(fos);
        pw.write(buf.toString().toCharArray());
        pw.flush();
        flag = true;
    } catch (IOException e1) {
        throw e1;
    } finally {
        if (pw != null) {
            pw.close();
        }
        if (fos != null) {
            fos.close();
        }
        if (br != null) {
            br.close();
        }
        if (isr != null) {
            isr.close();
        }
        if (fis != null) {
            fis.close();
        }
    }
    return flag;
}

工具类:

ConstantUtil.java工具类:

package com.framework.webClient.util;

import java.util.HashMap;
import java.util.Map;

/**
 * 
 * 文件名 ConstantUtil 描述 常量工具类
 * 
 * @author 简陌刀丶阿吉 创建日期 2018年5月28日
 */
public class ConstantUtil {

/**
 * 总数常量KEY
 */
public static final String TOTAL = "total";

/**
 * 数据常量KEY
 */
public static final String ROWS = "rows";

/**
 * 消息KEY常量
 */
public static final String MSG = "message";

/**
 * 消息状态KEY常量
 */
public static final String STATUS = "status";

/**
 * sheetName字符串常量
 */
public static final String SHEETNAME = "sheetName";

/**
 * 常量字符串0
 */
public static final String STATUS_ZERO = "0";

/**
 * 常量字符串1
 */
public static final String STATUS_ONE = "1";

/**
 * 常量字符串-1
 */
public static final String STATUS_FUONE = "-1";

/**
 * 常量整型0
 */
public static final int COMMONS_ZERO = 0;

/**
 * 常量整型1
 */
public static final int COMMONS_ONE = 1;

/**
 * 操作成功
 */
public static final String COMMON_SUCCESS = "操作成功";

/**
 * 操作失败
 */
public static final String COMMON_FAILURE = "操作失败";

/**
 * 未知原因导致的失败提示消息常量
 */
public static final String COMMON_WZYY_FAILURE = "由于未知原因导致操作失败,请联系管理员。";

/**
 * 模版名称字符串常量
 */
public static final String MBMC_KEY = "mbmc";

/**
 * 模版编号字符串常量
 */
public static final String MBBH_KEY = "mbbh";

/**
 * "模版名称存在,请更换"字符串常量
 */
public static final String MBMC_STRING_HAVE = "模版名称存在,请更换";

/**
 * "模版编号存在,请更换"字符串常量
 */
public static final String MBBH_STRING_HAVE = "模版编号存在,请更换";

/**
 * tag字符串常量
 */
public static final String TAG_KEY = "tag";

/**
 * dataList字符串常量
 */
public static final String DATALIST_KEY = "dataList";

/**
 * 上传文件失败字符串常量
 */
public static final String COMMON_UPLOAD_FAILE = "上传文件失败";

/**
 * 上传文件成功字符串常量
 */
public static final String COMMON_UPLOAD_SUCCESS = "上传文件成功";

/**
 * "text"字符串常量
 */
public static final String TEXT_KEY = "text";

/**
 * 文本分区类型: 0
 */
public static final String FQLX_TXT_ZERO = "0";

/**
 * 文本分区类型: 1
 */
public static final String FQLX_IMG_ONE = "1";

/**
 * 文本分区类型: 2
 */
public static final String FQLX_VOID_TWO = "2";

/**
 * 是否使用全部的标志tag
 */
public static final String COMMON_TAG = "tag";

/**
 * 全部的常量
 */
public static final String COMMON_QUANBU = "全部";

/**
 * 线路ID常量
 */
public static final String COMMON_XLID = "xlid";

/**
 * 线路名称常量
 */
public static final String COMMON_XLMC = "xlmc";

/**
 * 线路名称常量
 */
public static final String COMMON_LPMC = "lpmc";

/**
 * 空串常量
 */
public static final String NULL_STRING = "";

/**
 * led方向
 */
public static final String LEDFX_VALUE = "15";

/**
 * 方向
 */
public static final String FX_VALUE = "16";

/**
 * 属性类型对应字段编号
 */
public static final Map<String, Object> LED_ATTR_COMMONSET_MAP = new HashMap<>();
static {
    LED_ATTR_COMMONSET_MAP.put("font-size", "5");
    LED_ATTR_COMMONSET_MAP.put("font-style", "6");
    LED_ATTR_COMMONSET_MAP.put("font-weight", "7");
    LED_ATTR_COMMONSET_MAP.put("show-style", "8");
    LED_ATTR_COMMONSET_MAP.put("move-speed", "9");
    LED_ATTR_COMMONSET_MAP.put("sound-flag", "10");
    LED_ATTR_COMMONSET_MAP.put("sound-volume", "11");
    LED_ATTR_COMMONSET_MAP.put("sound-speed", "12");
    LED_ATTR_COMMONSET_MAP.put("sound-count", "13");
    LED_ATTR_COMMONSET_MAP.put("replay-count", "14");

}

/**
 * JcsjService字符串常量
 */
public static final String JCSJSERVICE_KEY = "JcsjService";

/**
 * 用户名常量
 */
public static final String COMMON_USER_NAME = "userName";

/**
 * dataList字符串常量KEY
 */
public static final String DATALIST = "dataList";

/**
 * 导入数据集合KEY常量
 */
public static final String IMPORTLIST = "importData";

/**
 * 数据key常量
 */
public static final String COMMON_DATA = "data";

/**
 * 导入Excel文件列标题变量名
 */
public static final String ANY_CONSTANT_IMPORT_TITLEVAR = "ledmc,ledbh,jd,wd,ledfx,csmbmc,wg,bdsbipdz,zwym,fqmbmc,stationString";

/**
 * 导入Excel文件中数据起始行, 从0开始
 */
public static final int ANY_CONSTANT_IMPORT_DATAROW = 1;

/**
 * 导入Excel文件中数据总列数
 */
public static final int ANY_CONSTANT_IMPORT_COUNTCOL = 11;

/**
 * 导入Excel文件列标题
 */
public static final String ANY_CONSTANT_IMPORT_TITLE = "站牌名称,站牌编号,经度,纬度,方向,参数模板名称,网关,本地设备IP地址,子网掩码,分区模板名称,关联站点列表";

/**
 * 导入成功提示消息
 */
public static final String IMPORTEXCEL_SUCCESS = "导入成功";

/**
 * 导入异常提示消息
 */
public static final String IMPORTEXCEL_FAILE = "导入异常";

/**
 * Excel的表头不能为空,请使用标准模版。
 */
public static final String IMPORTEXCEL_TITLE_NULL = "Excel的表头不能为空,请使用标准模版。";

/**
 * Excel的表头不能为空,请使用标准模版。
 */
public static final String IMPORTEXCEL_TITLE_ERROR = "Excel的表头不正确,请使用标准模版。";

/**
 * 导入电子站牌访问请求接口常量
 */
public static final String IMPORTLEDEXCEL = "/importLedExcel";

/**
 * 导入电子站牌参数常量
 */
public static final String FILE = "file";

/**
 * 逗号常量
 */
public static final String DOUHAO = ",";

/**
 * errorMsg字符串常量
 */
public static final String ERRORMSG = "errorMsg";

/**
 * titleString字符串常量
 */
public static final String TITLESTRING = "titleString";

/**
 * IP正则表达式字符串常量
 */
public static final String IPREG = "^((25[0-5]|2[0-4]\\d|((1\\d{2})|([1-9]?\\d)))\\.){3}(25[0-5]|2[0-4]\\d|((1\\d{2})|([1-9]?\\d)))$";

/**
 * sheet页名称不能为空,请按照'线路名(运行方向)'的格式进行添加。例如:'801(上行)'常量
 */
public static final String SHEETNAME_CANNOT_NULL = "sheet页名称不能为空,请按照'线路名(运行方向)'的格式进行添加。例如:'801(上行)'";

/**
 * sheet页名称长度不符合规范,请保证sheet页名称长度在5-54之间'常量
 */
public static final String SHEETNAME_LENGTH_ERROR = "sheet页名称长度不符合规范,请保证sheet页名称长度在5-54之间'";

/**
 * sheet页获取的线路名称常量
 */
public static final String SHEETXLMC = "sheetXlmc";

/**
 * 上行常量
 */
public static final String SHANGXING = "上行";

/**
 * sheet页获取的运行方向常量
 */
public static final String SHEETYXFX = "sheetYxfx";

/**
 * sheet页获取的运行方向编码常量
 */
public static final String SHEETYXFXSTATUS = "sheetYxfxStatus";

/**
 * sheet页获取的运行方向上行编码值常量
 */
public static final String SHEETYXFX_SHANGXING = "0";

/**
 * 下行常量
 */
public static final String XIAXIGN = "下行";

/**
 * sheet页获取的运行方向下行编码值常量
 */
public static final String SHEETYXFX_XIAXING = "1";

/**
 * 导入错误消息文本字符串常量
 */
public static final String IMPORT_ERROR_MESSAGE = "cwxx";

/**
 * "filePath"字符串常量
 */
public static final String FILEPATH = "filePath";

/**
 * 的第字符串常量
 */
public static final String MESSAGE_DE_DI = "的第";

/**
 * 换行标记
 */
public static final String HUANHANG = "\r\n";

/**
 * 错误消息存储路径常量
 */
public static final String STATIC_FRONTEND_PROJECT_TEMPLATE = "/static/frontend/project/template/";

/**
 * UTF_8字符串常量
 */
public static final String UTF_8 = "UTF-8";

/**
 * .txt字符串常量
 */
public static final String WORD_TXT = ".txt";

/**
 * 导出错误文件
 */
public static final String DOWNERROEFILE = "/downErrorFile";

/**
 * user-agent字符串常量
 */
public static final String USER_AGENT = "user-agent";

/**
 * msie字符串常量
 */
public static final String MSIE = "msie";

/**
 * 错误信息
 */
public static final String ERRORFILENAME = "错误信息";

/**
 * like gecko字符串常量
 */
public static final String LIKE_GECKO = "like gecko";

/**
 *  ISO_8859_1字符串常量
 */
public static final String ISO_8859_1 = "iso-8859-1";
}

ImportExcel2007Util导入工具类:

package com.framework.webClient.util;

import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.xssf.usermodel.XSSFRow;

/**
 * 
 * 文件名  ImportExcel2007Util
 * 描述  导入Excel2007文件工具类
 * @auther 简陌刀丶阿吉
 * 创建日期  2018年5月28日
 */
public class ImportExcel2007Util {

/**
 * 返回消息:错误消息Key值ֵ
 */
private static final String ANY_CONSTANT_ERROR_MSG = "errorMsg";

/**
 * 标题字符串Key值
 */
private static final String ANY_CONSTANT_TITLE_STR = "titleString";

/**
 * 导入EXCEL文件格式版本不正确的提示ʾ
 */
private static final String ANY_CONSTANT_VERSION_ERROR = "请确认您上传的文件是EXCEL 2007格式的文件";

/**
 * 没有需要导入的数据的错误提示
 */
private static final String ANY_CONSTANT_NODATA_ERROR = "没有需要导入的数据";

/**
 * Excel格式不正确的错误提示
 */
private static final String ANY_CONSTANT_FORMAT_ERROR = "Excel格式不正确,导入的文件与导入模板的列数不匹配";

/**
 * sheetName名称常量
 */
private static final String ANY_CONSTANT_SHEET_NAME = "sheetName";

/**
 * doImmportExcel:导入、解析EXCEL. <br/>
 * 
 * @author 简陌刀丶阿吉
 * @param dataRow 起始行
 * @param stream 导入数据流
 * @param countColumn 上传excel总列数
 * @param colList 导入文件每列对应的名称集合
 * @return List 返回导入的Excel文件中的数据
 * @throws Exception
 * date: 2018年5月23日 14:54:27 <br/>
 */
@SuppressWarnings("resource")
public static List<Map<String, Object>> doImmportExcel(int dataRow, InputStream stream, int countColumn, List<String> colList) throws Exception {
    HSSFWorkbook wb = null;
    // 声明并初始化存储导入数据的容器
    List<Map<String, Object>> result = new ArrayList<Map<String, Object>>();
    // office2007工作区
    try {
        wb = new HSSFWorkbook(stream);
    } catch (Exception e) {
        throw new Exception(ANY_CONSTANT_VERSION_ERROR);
    }
    for (int h = 0; h < wb.getNumberOfSheets(); h++) {
        // 获取sheet名称
        String sheetName = wb.getSheetName(h);
        // 获得该工作区的第一个sheet
        HSSFSheet sheet = wb.getSheetAt(h);
        // 总共有多少行,从0开始ʼ
        int totalRows = sheet.getLastRowNum();
        if (totalRows - dataRow < 0) {
            throw new Exception(ANY_CONSTANT_NODATA_ERROR);
        }
        // 总列数
        int totalCols = sheet.getRow(dataRow - 1).getPhysicalNumberOfCells();
        if (totalCols != countColumn) {
            throw new Exception(ANY_CONSTANT_FORMAT_ERROR);
        }
        // 遍历数据行
        for (int i = dataRow; i <= totalRows; i++) {
            // 取得该行
            HSSFRow row = sheet.getRow(i);
            if (null != row) {
                Map<String, Object> map = new HashMap<String, Object>();
                // 遍历列名集合
                for (int j = 0; j < colList.size(); j++) {
                    Cell cell = row.getCell(j);
                    // 设置单元格类型为字符串,取出的所有数据都为字符串
                    cell.setCellType(Cell.CELL_TYPE_STRING);
                    map.put(colList.get(j), NullStringConvertUtil(String.valueOf(cell)));
                    map.put(ANY_CONSTANT_SHEET_NAME, sheetName);
                }
                result.add(map);
            }
        }
    }
    return result;
}

/**
 * 空字符串处理
 * @author 简陌刀丶阿吉
 * @param str 需要格式化的字符串
 * @return 去掉空格后的串
 */
public static String NullStringConvertUtil(String str) {
    if (str == null || str.trim().equals("null")) {
        str = "";
    }
    return str.trim();
}

/**
 * 
 * getImportExcelTitle:(获取导入Excel文件的标题行). <br/>
 * 
 * @author 简陌刀丶阿吉
 * @param dataRow 起始行
 * @param stream  导入数据流
 * @param countColumn 上传excel总列数
 * @param colList 导入文件每列对应的名称集合
 * @return List 返回导入的Excel文件中的标题行
 * @throws Exception
 * date: 2018年5月23日 上午10:08:23 <br/>
 */
public static Map<String, Object> getImportExcelTitle(int dataRow, InputStream stream, int countColumn, List<String> colList) {
    Map<String, Object> result = new HashMap<String, Object>();
    StringBuilder title = new StringBuilder();
    HSSFWorkbook wb = null;
    @SuppressWarnings("unused")
    int cellCount = 0;
    try {
        wb = new HSSFWorkbook(stream);
    } catch (Exception e) {
        result.put(ANY_CONSTANT_ERROR_MSG, ANY_CONSTANT_VERSION_ERROR);
    }
    // 获得该工作区的第一个sheet
    HSSFSheet sheet = wb.getSheetAt(0);
    // 总共有多少行,从0开始ʼ
    int totalRows = sheet.getLastRowNum();
    if (totalRows - dataRow < 0) {
        result.put(ANY_CONSTANT_ERROR_MSG, ANY_CONSTANT_NODATA_ERROR);
    }
    // 获得表头行索引,从0开始
    int titleRow = sheet.getFirstRowNum();
    // 总列数
    int totalCols = sheet.getRow(titleRow).getPhysicalNumberOfCells();
    if (totalCols != countColumn) {
        result.put(ANY_CONSTANT_ERROR_MSG, ANY_CONSTANT_FORMAT_ERROR);
    }
    // 获得表头内容
    if (null == result || result.isEmpty()) {
        if (titleRow >= 0 && titleRow == dataRow - 1) {
            // 获得表头行
            HSSFRow titleRowData = sheet.getRow(titleRow);
            if (null != titleRowData) {
                if (null == colList || colList.size() == 0) {
                    // 检查数据是否存在空行
                    for (int i = titleRow; i <= totalRows; i++) {
                        // 取得该行
                        HSSFRow row = sheet.getRow(i);
                        // 每行空单元格计数
                        cellCount = 0;
                        // 循环每行的单元格
                        for (int j = row.getFirstCellNum(); j <= row.getLastCellNum(); j++) {
                            // 判断当前单元格是否为空
                            Cell cell = row.getCell(j, XSSFRow.RETURN_BLANK_AS_NULL);
                            if (null == cell) {
                                cellCount++;
                            }
                        }
                    }
                    for (int i = 0; i < totalCols; i++) {
                        title.append(NullStringConvertUtil(String.valueOf(titleRowData.getCell(i))));
                        if (i < (totalCols - 1)) {
                            title.append(",");
                        }
                    }
                } else {
                    // 遍历列名集合
                    for (int i = 0; i < colList.size(); i++) {
                        // 将定义的列名代号与导入文件中的列名匹配并存储到map容器中
                        result.put(colList.get(i), NullStringConvertUtil(String.valueOf(titleRowData.getCell(i))));
                    }
                }
            }
        }
    }
    if (title.length() > 0) {
        result.put(ANY_CONSTANT_TITLE_STR, title.toString());
    }
    return result;
}

/**
 * 
 * getImportExcelTitle:(获取导入Excel文件的标题行). <br/>
 * 
 * @author 简陌刀丶阿吉
 * @param dataRow
 *            起始行
 * @param stream
 *            导入数据流
 * @param countColumn
 *            上传excel总列数
 * @param colList
 *            导入文件每列对应的名称集合
 * @return List 返回导入的Excel文件中的标题行
 * @throws Exception
 *             date: 2018年5月23日 上午10:08:23 <br/>
 */
public static Map<String, Object> getImportExcelTitlePb(int dataRow, InputStream stream, int countColumn, List<String> colList, int sheetIndex) {
    Map<String, Object> result = new HashMap<String, Object>();
    StringBuilder title = new StringBuilder();
    HSSFWorkbook wb = null;
    @SuppressWarnings("unused")
    int cellCount = 0;
    try {
        wb = new HSSFWorkbook(stream);
    } catch (Exception e) {
        result.put(ANY_CONSTANT_ERROR_MSG, ANY_CONSTANT_VERSION_ERROR);
    }
    // 获得该工作区的第一个sheet
    HSSFSheet sheet = wb.getSheetAt(sheetIndex);
    // 总共有多少行,从0开始ʼ
    int totalRows = sheet.getLastRowNum();
    if (totalRows - dataRow < 0) {
        result.put(ANY_CONSTANT_ERROR_MSG, ANY_CONSTANT_NODATA_ERROR);
    }
    // 获得表头行索引,从0开始
    int titleRow = sheet.getFirstRowNum();
    // 总列数
    int totalCols = sheet.getRow(titleRow).getPhysicalNumberOfCells();
    if (totalCols != countColumn) {
        result.put(ANY_CONSTANT_ERROR_MSG, ANY_CONSTANT_FORMAT_ERROR);
    }
    // 获得表头内容
    if (null == result || result.isEmpty()) {
        if (titleRow >= 0 && titleRow == dataRow - 1) {
            // 获得表头行
            HSSFRow titleRowData = sheet.getRow(titleRow);
            if (null != titleRowData) {
                if (null == colList || colList.size() == 0) {
                    // 检查数据是否存在空行
                    for (int i = titleRow; i <= totalRows; i++) {
                        // 取得该行
                        HSSFRow row = sheet.getRow(i);
                        // 每行空单元格计数
                        cellCount = 0;
                        // 循环每行的单元格
                        for (int j = row.getFirstCellNum(); j <= row.getLastCellNum(); j++) {
                            // 判断当前单元格是否为空
                            Cell cell = row.getCell(j, XSSFRow.RETURN_BLANK_AS_NULL);
                            if (null == cell) {
                                cellCount++;
                            }
                        }
                    }
                    for (int i = 0; i < totalCols; i++) {
                        title.append(NullStringConvertUtil(String.valueOf(titleRowData.getCell(i))));
                        if (i < (totalCols - 1)) {
                            title.append(",");
                        }
                    }
                } else {
                    // 遍历列名集合
                    for (int i = 0; i < colList.size(); i++) {
                        // 将定义的列名代号与导入文件中的列名匹配并存储到map容器中
                        result.put(colList.get(i), NullStringConvertUtil(String.valueOf(titleRowData.getCell(i))));
                    }
                }
            }
        }
    }
    if (title.length() > 0) {
        result.put(ANY_CONSTANT_TITLE_STR, title.toString());
    }
    return result;
}

/**
 * doImmportExcel:导入、解析EXCEL. <br/>
 * 
 * @author 简陌刀丶阿吉
 * @param dataRow
 *            起始行
 * @param stream
 *            导入数据流
 * @param countColumn
 *            上传excel总列数
 * @param colList
 *            导入文件每列对应的名称集合
 * @return List 返回导入的Excel文件中的数据
 * @throws Exception
 *             date: 2018年5月23日 14:54:27 <br/>
 */
@SuppressWarnings("resource")
public static List<Map<String, Object>> doImmportExcelPb(int dataRow, InputStream stream, int countColumn, List<String> colList, int sheetIndex)
        throws Exception {
    HSSFWorkbook wb = null;
    // 声明并初始化存储导入数据的容器
    List<Map<String, Object>> result = new ArrayList<Map<String, Object>>();
    // office2007工作区
    try {
        wb = new HSSFWorkbook(stream);
    } catch (Exception e) {
        throw new Exception(ANY_CONSTANT_VERSION_ERROR);
    }
    // 获得该工作区的第一个sheet
    HSSFSheet sheet = wb.getSheetAt(sheetIndex);
    // 总共有多少行,从0开始ʼ
    int totalRows = sheet.getLastRowNum();
    if (totalRows - dataRow < 0) {
        throw new Exception(ANY_CONSTANT_NODATA_ERROR);
    }
    // 总列数
    int totalCols = sheet.getRow(dataRow - 1).getPhysicalNumberOfCells();
    if (totalCols != countColumn) {
        throw new Exception(ANY_CONSTANT_FORMAT_ERROR);
    }
    String sheetName = wb.getSheetName(sheetIndex);
    // 遍历数据行
    for (int i = dataRow; i <= totalRows; i++) {
        // 取得该行
        HSSFRow row = sheet.getRow(i);
        if (null != row) {
            Map<String, Object> map = new HashMap<String, Object>();
            // 遍历列名集合
            for (int j = 0; j < colList.size(); j++) {
                Cell cell = row.getCell(j);
                // 设置单元格类型为字符串,取出的所有数据都为字符串
                if (cell == null) {
                    map.put(colList.get(j), "");
                } else {
                    cell.setCellType(Cell.CELL_TYPE_STRING);
                    map.put(colList.get(j), NullStringConvertUtil(String.valueOf(cell)));
                }
            }
            map.put(ConstantUtil.SHEETNAME, sheetName);
            result.add(map);
        }
    }
    return result;
}
}

相关文章

网友评论

      本文标题:java导入excel,错误返回消息生成txt文档,并指定错误消

      本文链接:https://www.haomeiwen.com/subject/fudgnftx.html