zoukankan      html  css  js  c++  java
  • jsp导出excel 解决文件名中文乱码

         WritableWorkbook wwb=null;
         WritableSheet ws=null;
         OutputStream os = response.getOutputStream();
        wwb = Workbook.createWorkbook(os);
        ws=wwb.createSheet("员工编号",0);
        ws.getSettings().setDefaultColumnWidth(15);
        ws.setColumnView(0,20);
        ws.setColumnView(1,20);
        ws.setColumnView(2,80);
        Label label = new Label(0,0,"日期");  // 列 行 名称
        ws.addCell(label);
         label = new Label(1,0,"薪资");
        ws.addCell(label);
        label = new Label(2,0,"增幅");
        ws.addCell(label);
        response.setContentType("application/vnd.ms-excel");
        response.setHeader("Content-disposition","attachment; filename="+ new String((titlename).getBytes("gbk"),"iso8859-1")+".xls");
        if(null!=pro_List && pro_List.size()>0){
            Map oneMap = null ;
            for(int i=0;i<pro_List.size();i++){
                oneMap = pro_List.get(i) ;
                label = new Label(0,(i+1),CommonString.getFormatPara(oneMap.get("date"))) ;
                ws.addCell(label);
                label = new Label(1,(i+1),CommonString.getFormatPara(oneMap.get("money"))) ;
                ws.addCell(label);
                label = new Label(2,(i+1),CommonString.getFormatPara(oneMap.get("amplification")).equals("")?"0":CommonString.getFormatPara(oneMap.get("amplification"))+"%") ;
                ws.addCell(label);
            }
        }
        wwb.write();
        wwb.close();
        os.close();
        os = null ;
        response.flushBuffer();  
        out.clear();  
        out = pageContext.pushBody();

  • 相关阅读:
    Beetl 3中文文档 转载 http://ibeetl.com/guide/
    Beetl模板引擎入门教程
    Spring+Stomp+ActiveMq实现websocket长连接
    5672端口引发的一个大坑
    GeoServer中WMS、WFS的请求规范
    常用网址
    JAVA方法参数传递
    针对开发的缺陷管理
    不同逻辑顺序产生相同的结果编码如何决策
    怎样做一个软件项目经理
  • 原文地址:https://www.cnblogs.com/javawebsoa/p/2990587.html
Copyright © 2011-2022 走看看