您的位置:首页 > Web前端 > HTML

使用Docx4J生成 html

2014-02-24 01:48 281 查看
开源Docx4J 将docx文档转换成html文档

使用maven导入docx4j包

<dependency>
<groupId>org.docx4j</groupId>
<artifactId>docx4j</artifactId>
<version>3.0.1</version>
</dependency>

简单的测试访求

public static void docxToHtml(String filepath, String outpath) throws Docx4JException, FileNotFoundException{
WordprocessingMLPackage wmp = WordprocessingMLPackage.load(new File(filepath));
Docx4J.toHTML(wmp, "html/resources", "resources", new FileOutputStream(new File(outpath)));
}

public static void main(String[] args) throws Exception{
DocToHtml.docxToHtml("test.docx", "html/test.html");
}

这样就可以将docx文档转换成html文档,但是因为 文件格式的问题,不能转换doc文档
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: