文件导出步骤:
引入问价导入导出的相关java文件; 如需要可联系qq
1、建立导出的按钮
2、导出时的提示
$("#btnExport").click(function(){ top.$.jBox.confirm("确认要导出运营数据吗?","系统提示",function(v,h,f){ if(v=="ok"){ var searchAction = $("#searchForm").attr("action"); $("#searchForm").attr("action","${ctx}/operation/operationData/export");//路径 $("#searchForm").submit(); $("#searchForm").attr("action",searchAction); } },{buttonsFocus:1}); top.$('.jbox-body .jbox-icon').css('top','55px'); });
3、在控制器中方法
/** * 导出数据(有实体) * * @return */ @RequiresPermissions("operation:operationData:view") @RequestMapping(value = "export", method=RequestMethod.POST) public String exportFile(OperationData operationData, HttpServletRequest request, HttpServletResponse response, Model model, RedirectAttributes redirectAttributes) { try { String fileName = "文件名称"+DateUtils.getDate("yyyyMMddHHmmss")+".xlsx"; Listlist = operationDataService.findList(operationData); new ExportExcel("文件名称(起始时间:"+StringUtils.replaceNull(DateUtils.formatDate(operationData.getBeginDt(), "yyyy-MM-dd"), "不限制")+",结束时间:"+StringUtils.replaceNull(DateUtils.formatDate(operationData.getEndDt(), "yyyy-MM-dd"), "不限制")+")", OperationData.class).setDataList(list).write(response, fileName).dispose(); return null; } catch (Exception e) { addMessage(redirectAttributes, "导出运营数据失败!失败信息:"+e.getMessage()); } return "redirect:" + adminPath + "/modules/operation/operationDataList?repage"; }/** * 导出数据(无实体) * * @return */ @RequiresPermissions("operation:projectOperation:view") @RequestMapping(value = "export", method=RequestMethod.POST) public String exportFile(ProjectBaseInfo projectBaseInfo, HttpServletRequest request, HttpServletResponse response, Model model, RedirectAttributes redirectAttributes) { try { String fileName = "导出的文件名称"+DateUtils.getDate("yyyyMMddHHmmss")+".xlsx"; List
4、在导出的pojo中加入注解
在get上加入@ExcelField(title="名称", align=2, sort=20)