POI 4.1.2 word转html(保留样式及图片) |
您所在的位置:网站首页 › java读取word内容保留格式 › POI 4.1.2 word转html(保留样式及图片) |
因为自己的任务需要用到word转html,但是poi3.1.2的版本与我poi4.1.2版本冲突,所以尝试用4.1.2版本来写一个word转html,它是可以同时支持doc和docx两种格式,非常好用,当前文章是关于docx转html的,doc相对来说比较简单,有兴趣的可以尝试一下 本文章暂时为docx转html!!!! 开发工具:idea 项目管理工具:maven 不多说,直接撸代码 1、首先配置pom.xml文件,具体配置如下 org.apache.poi 中的 POI-OOXML 与 POI 的版本都是4.1.2!!!!!! org.apache.poi poi-ooxml 4.1.2 org.apache.poi poi 4.1.2 fr.opensagres.xdocreport fr.opensagres.poi.xwpf.converter.xhtml 2.0.2 这里配置完之后,注意查看依赖内版本是否为4.1.2 可能会出现maven配置的是4.1.2,但是以来的确实其他版本的情况poi与poi-ooxml的版本需要一致。 2.工具类的开发 import com.ruoyi.common.config.AliConfig; import com.ruoyi.common.utils.LocalDateUtil; import com.ruoyi.common.utils.OssUtil; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.service.constants.ColumnEnum; import com.ruoyi.service.service.impl.ImageManagerImpl; //重点!! 这里用到了下面继承的ImageManagerImpl import fr.opensagres.poi.xwpf.converter.xhtml.XHTMLConverter; // 注意路径名称 import fr.opensagres.poi.xwpf.converter.xhtml.XHTMLOptions; // 注意路径名称 import lombok.Cleanup; import lombok.extern.slf4j.Slf4j; import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.ObjectUtils; import org.apache.poi.xwpf.usermodel.XWPFDocument; import java.io.*; import java.nio.charset.StandardCharsets; import java.time.LocalDateTime; import java.util.HashMap; import java.util.List; import java.util.Map |
今日新闻 |
点击排行 |
|
推荐新闻 |
图片新闻 |
|
专题文章 |
CopyRight 2018-2019 实验室设备网 版权所有 win10的实时保护怎么永久关闭 |