poi替换word模板中的关键字实现jacod效果

大明1986 2013-08-08 04:28:44
这几天在做报表,highcharts生成图表以及一些数据文字,然后通过后台代码套用word模板生成word文件。
一开始jacob替换关键字实现,后领导说服务器马上迁移到linux下,想问poi能否实现类似效果。
求大神帮忙 给个demo
...全文
83 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
星閃月爍 2013-08-08
  • 打赏
  • 举报
回复
噢,poi沒有用到,你百度搜一下,有很多例子的
星閃月爍 2013-08-08
  • 打赏
  • 举报
回复
//把DB數據寫入word模板 public boolean PrintWord(String strPath,String mgYear,String strCostName,String ChResultNote1,String ChResultNote2,String strUserID) { try { configuration = new Configuration(); configuration.setDefaultEncoding("UTF-8"); Map dataMap=new HashMap(); dataMap.put("Year", mgYear); dataMap.put("strCostName", strCostName); dataMap.put("ChResultNote1",ChResultNote1); dataMap.put("ChResultNote2",ChResultNote2); File ftl = new File(strPath+"\\download\\Report\\評核成績彙總表.ftl"); configuration.setDirectoryForTemplateLoading(ftl.getParentFile()); Template t=null; t = configuration.getTemplate(ftl.getName()); t.setEncoding("UTF-8"); File outFile = new File(strPath+"\\download\\Report\\評核成績彙總表_"+strUserID+".doc"); Writer out = null; out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outFile), "UTF-8")); t.process(dataMap, out); out.close(); } catch(Exception e) { System.out.println(e.toString()); return false; } return true; }

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧