zoukankan      html  css  js  c++  java
  • 导出Excel格式数据

      /**
         * 导出规则统计数据 excel格式
         * @param bill
         * @return
         */
        public String exportExamsignupExamnoExcel ( String tablename )
        {
            try
            {
                String filename = System.currentTimeMillis() + ".xls";
                ExcelTool excelTool = Global.getInstance().getExcelTool();
                ArrayList<EntityBean> rows = new ArrayList<EntityBean>();
                SearchParameters par = new SearchParameters();
                par.setName("LBIDrulecountbytable");
                par.addParameter("tablename", tablename, 11);
                EntityBean[] beanlst = par.beanSearch();
                if ( beanlst != null && beanlst.length > 0 )
                {
    
                    EntityBean bean_tname = new EntityBean();
                    EntityBean bean_rule = new EntityBean();
                    EntityBean bean_count = new EntityBean();
                    EntityBean bean_percent = new EntityBean();
    
                    bean_tname.put("tablename", "表名");
                    bean_rule.put("rule", "规则名");
                    bean_count.put("counts", "符合规则量");
                    bean_percent.put("percents", "占比");
                    
                    for (int i = 0; i < beanlst.length; i++)
                    {
                        EntityBean ubean = beanlst[i];
    
                        bean_tname.put("tablename"+i, ubean.getString("tablename"));
                        bean_rule.put("rule"+i, ubean.getString("rule"));
                        bean_count.put("counts"+i, ubean.getString("counts"));
                        bean_percent.put("percents"+i, ubean.getString("percents"));
    
                    }
                    rows.add(bean_tname);
                    rows.add(bean_rule);
                    rows.add(bean_count);
                    rows.add(bean_percent);
                    excelTool.addValue("list", rows);
                    if ( !new File(Global.getInstance().getRootPath() + "/ExcelReports/").exists() )
                    {
                        new File(Global.getInstance().getRootPath() + "/ExcelReports/").mkdirs();
                    }
                    File file = new File(Global.getInstance().getRootPath() + "/ExcelReports/" + filename);
                    if ( file != null && file.exists() )
                    {
                        file.delete();
                    }
                    if ( this.getContext().getCurrentApplicationSysCode().equals("12.002000000000000000000000000000000") )
                    {
                        excelTool.export(Global.getInstance().getRootPath() + "/ExcelTemplate/LBIDmodule.xls", Global.getInstance()
                                .getRootPath() + "/ExcelReports/" + filename);
                    }
                    else
                    {
                        excelTool.export(Global.getInstance().getRootPath() + "/ExcelTemplate/LBIDmodule.xls", Global.getInstance()
                                .getRootPath() + "/ExcelReports/" + filename);
                    }
                    return filename;
                }
            }
            catch (Exception e)
            {
                Global.getInstance().LogError(this, e);
                e.printStackTrace();
                return null;
            }
            return null;
        }
  • 相关阅读:
    点击新闻弹出新闻内容,并且新闻内容根据鼠标移动
    阻止用户复制页面上的文字的几种方法
    js简易聊天框- 鼠标和回车键发送消息
    Java——package和import关键字
    Java——static关键字
    Java——单例模式初步
    Java——this关键字
    Java面向对象的特征一:封装性
    Java再谈方法
    Java——对象
  • 原文地址:https://www.cnblogs.com/zhaojinhui/p/3998538.html
Copyright © 2011-2022 走看看