word,excel,ppt,mht,pdf等文件如何转成html源码
作者:楚天龙-zhangqingbiao
第一步:需要检查你的源文件是什么编码格式。尽量保证和你的项目编码格式一直,否则很容易出行IE正常访问,但是其他浏览器不能正常访问。
第二步:不说太多,直接上干货,详细操作流程如下:
第三步:引入jacob.jar包,如果找不到jar包,这个jar包是本人自己重新改造的jar包,有需要的,可以私信我。
<dependency>
<groupId>com.jacob</groupId>
<artifactId>jacob</artifactId>
<version>1.2.0</version>
</dependency>
第四步;核心代码,编写一个HtmlUtills类,里面针对各种文档格式转html,下面以word为例子:
public boolean WordtoHtml(String orignFileStr, String destinationFileStr) {
ComThread.InitSTA();
ActiveXComponent activexcomponent = new ActiveXComponent(
“Word.Application”);
boolean flag = false;
try {
a