当前位置: 首页 > news >正文

使用poi-tl动态写入目录更新问题解决

在使用poi-tl动态写完word后,是无法更新目录的,使用poi-tl提供的插件也是不行的,而且很多使用poi手动写入的也是不行,最多就是让你在打开文件时提示你更新目录/更新域,用户体验很差,要点击好几次而且wps还不一定会弹的出来,只有office可以弹框。所以全网搜索最终找到两种解决方案,亲测可用,包含附件破解jar包,当然有商业版的更好

引入破解jar包,并导入项目,在资源里下载
spire.doc.free-5.2.0.jar
aspose-words-20.12-jdk17-crack.jar
在项目里的resources目录下新增lib文件夹将jar放入,打开pom文件夹配置

1,使用spire.doc(耗时长)

        <dependency><groupId>e-iceblue</groupId><artifactId>spire.doc.free</artifactId><version>5.2.0</version><scope>system</scope><systemPath>${project.basedir}/src/main/resources/lib/ spire.doc.free-5.2.0.jar</systemPath></dependency>
  public static void main(String[] args) throws Exception {String wordPath = "D:\word\template\test.docx"Document dd = new Document(wordPath);// 更新目录dd.updateTableOfContents();// 再保存到原文件或者保存到新文件地址都可以dd.saveToFile(wordPath);
}

2,使用aspose.words

        <dependency><groupId>com.aspose</groupId><artifactId>aspose-words</artifactId><version>20.12</version><scope>system</scope><systemPath>${project.basedir}/src/main/resources/lib/aspose-words-20.12-jdk17-crack.jar</systemPath></dependency>
  public static void main(String[] args) throws Exception {String wordPath = "D:\word\template\test.docx"Document doc = new Document(wordPath );// 更新目录doc.updateFields();// 再保存到原文件或者保存到新文件地址都可以doc.save(wordPath);
}
  // aspose 还提供很多转换功能比如转pdfpublic static void main(String[] args) throws Exception {String wordPath = "D:\word\template\test.docx"String pdfPath = "D:\word\template\testPdf.pdf"File file = new File(pdfPath);try (FileOutputStream os = new FileOutputStream(file)) {Document doc = new Document(pdfPath);doc.updateFields();doc.save(os, SaveFormat.PDF);}   
}

打包会遇到的一点小坑

当使用system引入依赖时,打包的时候要多注意,要加上如下配置,不然springboot是不会这种方式引入的jar进行打包的。

<build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId><!-- 打包时会将本地jar一起打包 --><configuration><includeSystemScope>true</includeSystemScope></configuration>     </plugin></plugins>
</build>

参考连接

http://www.lryc.cn/news/463569.html

相关文章:

  • OpenCV高级图形用户界面(9)更改指定窗口的位置函数moveWindow()的使用
  • 华山论剑之Rust的Trait
  • AI 编译器学习笔记之七五 -- pdb 使用方法
  • 15分钟学Go 第8天:控制结构 - 循环
  • 后端接收参数的几种常用注解
  • 如何使用docker在linux中配置C++环境
  • darknet_ros 使用教程
  • 第九课 Vue中的v-bind指令拓展
  • DOIP协议介绍2-Diagnostic power mode information request (0x4003)消息
  • Eclipse 软件:配置 JDBC、连接 MySQL 数据库、导入 jar 包
  • 二叉树中的最长交错路径
  • 高校企业数据可视化平台功能介绍/特色功能
  • RHCE第三次笔记SSH
  • JAVA基础-包装类
  • 复合逻辑运算与复合逻辑门
  • 工厂模式~
  • Elasticsearch基本使用及介绍
  • 10. PH47代码框架文件组织
  • LabVIEW提高开发效率技巧----VI继承与重载
  • 4.8 大数据发展趋势
  • 【无标题】react组件封装
  • git+cmake将Open3D配置到visual studio
  • ArcGIS-CityEngine 2024-新手小白也能试用+入门可视化vga编程--第一篇
  • IntelliJ IDEA 快捷键大全(也适用全家桶其他编辑器)
  • 基于SSM高校普法系统的设计
  • CDN加速流程分享
  • 全网爆火的排队免单模式究竟是如何运作?
  • Excel:vba实现批量修改文件名
  • 【数据分享】中国历史学年鉴(1979-2001)
  • ubuntu系统启动wmplayer提示vmware unable to install all modules的处理方法