根据模板导出excel java编写

时间:2016-02-21 05:46:04
【文件属性】:
文件名称:根据模板导出excel java编写
文件大小:2.41MB
文件格式:RAR
更新时间:2016-02-21 05:46:04
根据模板 导出 excel java 根据excel模版导出excel,核心代码如下: /*-------------- 1.准备数据--------------*/ List<Object> resultList = new ArrayList<Object>(); Date todays = new Date();//日期 List<Object> countList = new ArrayList<Object>();//行数据 countList.add("A-001");//类别 countList.add(20L);//数量 resultList.add(countList); countList = new ArrayList<Object>();//行数据 countList.add("A-002");//类别 countList.add(24L);//数量 resultList.add(countList); int counts = 60; ExcelUtils.addValue("typename","运输类"); ExcelUtils.addValue("counts",counts); ExcelUtils.addValue("todays",todays); ExcelUtils.addValue("resultList", resultList); /*-------------- 2.写出excel文件--------------*/ String dirs = this.getProjectDirs() + "template/"; String templateFileName = "AircraftType";//模版名称(不含扩张名) AircraftType String templateFilePath = dirs + templateFileName + ".xls"; String destFilePath = dirs + templateFileName + "-out.xls"; try { System.out.println("templateFilePath="+templateFilePath); OutputStream out = new FileOutputStream(destFilePath); ExcelUtils.export(templateFilePath, out); System.out.println("destFilePath="+destFilePath); } catch (ExcelException e) { e.printStackTrace(); } catch (FileNotFoundException e) { e.printStackTrace(); }
【文件预览】:
excel
----.settings()
--------org.eclipse.wst.jsdt.ui.superType.name(6B)
--------org.eclipse.wst.common.project.facet.core.xml(252B)
--------org.eclipse.wst.common.component(532B)
--------org.eclipse.wst.jsdt.ui.superType.container(49B)
--------.jsdtscope(500B)
--------org.eclipse.jdt.core.prefs(395B)
----src()
--------com()
----.project(1KB)
----WebRoot()
--------META-INF()
--------WEB-INF()
--------index.jsp(834B)
----resource()
--------template()
----.mymetadata(288B)
----.classpath(576B)
----.myeclipse()

网友评论

  • 到还是可以吧。只能借鉴下而已
  • 还可以,功能可以实现
  • 被坑了 白瞎我的积分了 一点都不好
  • 很有用,谢谢了
  • 还可以,还是比较实用的
  • 实现还不错,有些介绍Excel里面的语法
  • 实现还不错,有些介绍Excel里面的语法就好了,整体写得还是比较简单。
  • 不是我想要的ftl方式导出,不太适用
  • 非常好的实现方式
  • 不是我想要的ftl方式导出,不太适用