poi导出excel

来源:互联网 发布:申请网络预约出租车 编辑:程序博客网 时间:2024/06/05 02:50
页面:
<href="###" class="btn1 btn-search" id="upLoadButton" onclick="exportFile()"><span><em>导出</em></span></a>
js:
//导出
function exportFile() {
    var data _$.getAjaxData({
        urlbasePath '/webresources/timeeffect/exportFile',
        type'POST',
        dataType'json',
        datagetQueryParams('form')
    });
    if (data.success) {
        _$.alert(null"点击确定,下载导出文件!"nullfunction () {
            window.location.href '<%=path%>/downloader?filename=' data.msg '&ExportOrDownLoad=Export';
        });
    } else {
        _$.alert(null"导出失败"nullfunction () {
        });
    }
}//end 导出

后台:
@POST
@Path("/exportFile")
public EasyUIResult exportAll( @FormParam("province")  String provicecode,
                               @FormParam("city")  String citycode,
                               @FormParam("wmscode")  String wmscode,
                               @FormParam("logistic")  String logisticcode) {
    EasyUIResult result = null;
    TimeEffectVO timeEffectVO = new TimeEffectVO();
    if (!org.apache.commons.lang3.StringUtils.isEmpty(provicecode)) {
        timeEffectVO.setProvicecode(provicecode);
    }
    if (!org.apache.commons.lang3.StringUtils.isEmpty(citycode)) {
        timeEffectVO.setCitycode(citycode);
    }
    if (!org.apache.commons.lang3.StringUtils.isEmpty(wmscode)) {
        timeEffectVO.setWmscode(wmscode);
    }
    if (!org.apache.commons.lang3.StringUtils.isEmpty(logisticcode)) {
        timeEffectVO.setLogisticcode(logisticcode);
    }

    String exportFile = this.teService.exportFile(timeEffectVO);
    if (!org.apache.commons.lang3.StringUtils.isEmpty(exportFile)) {
        result = EasyUIUtils.getEasyUIResult(1true);
        result.setMsg(exportFile);
        return result;
    }

    result = EasyUIUtils.getEasyUIResult(-1false);
    return result;
}

@Override
public String exportFile(TimeEffectVO record) {
   ExcelExportInfo exportInfo = new ExcelExportInfo();
   exportInfo.setFileName("TimeEffect_Export");
   exportInfo.setSheetName("excel_headers_chinese");
   exportInfo.setTitles(new String[]{"导出excel头"});
   exportInfo.setTitleWidths(new int[]{30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30});
   exportInfo.setDataColumns(new String[]{"excel_headers_english"});
   List<TimeEffectVO> datalist = this.timeEffectDao.getViewList(record);
   exportInfo.setDataList(datalist);
   String result = ExcelExportUtil.Export(exportInfo);
   return result;
}
原创粉丝点击