用freemarker生成word之后怎么样更新目录页码呢

var_Cui 2018-12-21 05:22:26
遇到一个很棘手的问题,freemarker生成word之后目录页码如何更新,在线等,很急
...全文
3186 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
var_Cui 2021-01-05
  • 打赏
  • 举报
回复
并没有 最后在生成的word里边设置的
朱颜_辞镜 2021-01-04
  • 打赏
  • 举报
回复
引用 楼主 var_Cui 的回复:
遇到一个很棘手的问题,freemarker生成word之后目录页码如何更新,在线等,很急
这个问题你解决了没
var_Cui 2019-04-16
  • 打赏
  • 举报
回复
你说的大批量更新是啥意思 ??? 好几个目录???
weixin_39090028 2019-04-16
  • 打赏
  • 举报
回复
这个支持大批量更新吗?我现在使用的是插入目录的方式,但种方式没法支持大批量文件更新,找不到解决方法....
十八道胡同 2019-04-11
  • 打赏
  • 举报
回复
引用 3 楼 var_Cui 的回复:
谢谢 这个我也知道了 但是这个只支持Windows环境 在Linux是不支持的
var_Cui 2019-04-11
  • 打赏
  • 举报
回复
谢谢 这个我也知道了 但是这个只支持Windows环境 在Linux是不支持的
weixin_44658318 2019-03-22
  • 打赏
  • 举报
回复
结合jacob可以更新目录 package com.key.words.convert; import com.jacob.activeX.ActiveXComponent; import com.jacob.com.Dispatch; import com.jacob.com.Variant; public class WordCatalog { /** * 目录生成 * @param oldPath 源文件 * @param wirtePath 存储路径 * @return */ public static void updateWord(String oldPath,String wirtePath){ ActiveXComponent app = new ActiveXComponent("Word.Application"); //启动word try { //app.setProperty("Visible", new Variant(true)); //设置word不可见 app.setProperty("Visible", new Variant(false)); Dispatch docs = app.getProperty("Documents").toDispatch(); Dispatch doc = Dispatch.invoke(docs,"Open",Dispatch.Method, new Object[] { oldPath, new Variant(false),new Variant(true) }, new int[1]).toDispatch(); Dispatch activeDocument = app.getProperty("ActiveDocument").toDispatch(); /** * 更新目录部分代码 * * 获取目录*/ Dispatch tablesOfContents = Dispatch.get(activeDocument,"TablesOfContents").toDispatch(); /**获取第一个目录。若有多个目录,则传递对应的参数*/ Variant tablesOfContent = Dispatch.call(tablesOfContents,"Item", new Variant(1)); /**更新目录,有两个方法:Update 更新域,UpdatePageNumbers 只更新页码*/ Dispatch toc = tablesOfContent.toDispatch(); toc.call(toc,"Update"); System.out.println("另存完成"); Dispatch.call(doc, "SaveAs",wirtePath); //另存文件 Dispatch.call(doc, "Close", new Variant(false)); System.out.println("is over"); } catch (Exception e) { e.printStackTrace(); }finally{ app.invoke("Quit",new Variant[]{}); app.safeRelease(); } } }
var_Cui 2019-02-01
  • 打赏
  • 举报
回复
一个月了 没有大佬理下我吗

81,091

社区成员

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

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