码迷,mamicode.com
首页 > 编程语言 > 详细

test java

时间:2016-01-07 16:20:11      阅读:143      评论:0      收藏:0      [点我收藏+]

标签:

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

test java

标签:

原文地址:http://www.cnblogs.com/xiaoyy2012/p/5110140.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!