标签:
public Forward export(HttpServletRequest request,HttpServletResponse response) throws Exception{ String orgCode = request.getParameter("orgCode"); String begin = request.getParameter("begin"); String end = request.getParameter("end"); Page<Object[]> page = BdtDaoFactory.createLLDao().getJY(orgCode, begin, end, 0, 30); int[] widths = new int[]{10*512,14*512,14*512,12*512,7*512,7*512,15*512}; ExportWriter out = new POIExcelExportWriter(response.getOutputStream(),widths); String[] sx = new String[]{"jg","khzh","khmc","zjhm","qyrq","zhzl","msg"}; String[] mc = new String[]{"开户机构","客户账号","客户中文名","证件号码","签约日期","账户种类" ,"校验错误信息"}; ExportDescriptor ed = new ExportDescriptor("校验表", sx,mc); ed.setConverters(new ExportConverter[] { ConverterFactory.createDefaultConverter, ConverterFactory.createDefaultConverter, ConverterFactory.createDefaultConverter, ConverterFactory.createDefaultConverter, ConverterFactory.createDefaultConverter, ConverterFactory.createDefaultConverter, ConverterFactory.createDefaultConverter }); response.reset(); // 非常重要 String fileName = URLEncoder.encode(DateUtil.dateToString(new Date(), "yyyyMMddhhmmsss")+".xls", "UTF-8"); response.setContentType("application/x-msdownload"); response.setHeader("Content-Disposition", "attachment; filename=" + fileName); new ExportServiceImpl().export(out, page, ed); return null; }
标签:
原文地址:http://www.cnblogs.com/xiaoyy2012/p/5110140.html