本来用php转的 效果不太理想 很不稳定

最后试了下java 效果不错 只记录java的方法好了 其实他们的原理都是一样的啊,都是用到了微软的com

首先是准备工作

下载(明确dll的版本是64位的还是32位的)

把jar导入项目 把dll放入jdk的bin目录下 ok

package word2html;

import com.jacob.activeX.ActiveXComponent;
import com.jacob.com.ComException;
import com.jacob.com.Dispatch;
import com.jacob.com.Variant; public class word2html { public static boolean wordToHtml(String inPath, String toPath) {
// 启动word
ActiveXComponent axc = new ActiveXComponent("Word.Application"); boolean flag = false; try {
// 设置word不可见
axc.setProperty("Visible", new Variant(false)); Dispatch docs = axc.getProperty("Documents").toDispatch(); // 打开word文档
Dispatch doc = Dispatch.invoke(
docs,
"Open",
Dispatch.Method,
new Object[] { inPath, new Variant(false),
new Variant(true) }, new int[1]).toDispatch(); // 作为html格式保存到临时文件
Dispatch.invoke(doc, "SaveAs", Dispatch.Method, new Object[] {
toPath, new Variant(8) }, new int[1]); Variant f = new Variant(false);
Dispatch.call(doc, "Close", f);
flag = true;
return flag; } catch (Exception e) {
e.printStackTrace();
return flag;
} finally {
axc.invoke("Quit", new Variant[] {});
}
} public static void main(String[] args) { word2html.wordToHtml("D://123.docx","D://123.htm"); } }

然后是效果图

然后问题来了,怎么把生成好的html做成文章

1、文章名要有意义

2、按时间遍历静态的html,然后把他们的名字列出来,这是文章列表页

3、点击查看要能看到文章详情,就不是传id了,而是传文章路径

4、点击了文章路径肯定是能看到文章的

5、怎么显示为手机页呢?这就需要把页面包涵进来,用正则进行处理一下。

最新文章

  1. 使用visualvm远程监控JVM LINUX服务器配置方法
  2. JAVA用途
  3. iOS学习之单例模式
  4. highcharts 不显示X轴 Y轴 刻度
  5. eclispe常用快捷键
  6. R之data.table -melt/dcast(数据合并和拆分)
  7. Android-MediaProvider数据库模式
  8. Integrating JAD decompiler into JDeveloper(转)
  9. 每日一九度之 题目1040:Prime Number
  10. YARN应用程序的开发步骤
  11. #ifdef __cplusplus extern c #endif 的作用
  12. sqlplus乱码
  13. 一个经试用效果非常不错的数据库连接池--JAVA
  14. differ比较两个字符串的差异
  15. watch命令
  16. TypeScript教程2
  17. 给指针malloc分配空间后就等于数组吗?【转】
  18. 汇编指令-CMP、TEQ(5)
  19. Velocity(2)——常用语法
  20. Spring MVC 集成Disconf

热门文章

  1. React Conf 2017 干货总结 1: React + ES next = ♥
  2. TELNET终端类型选项
  3. sqlmap批量扫描burpsuite拦截的日志记录
  4. python--如何操作表
  5. centos7 minimal connect: Network is unreachable(转)
  6. PHP+MYSQL的搭建
  7. hibernate学习系列-----(8)hibernate对集合属性的操作之Collectioon集合篇
  8. 倍福TwinCAT(贝福Beckhoff)常见问题(FAQ)-如何配置虚拟轴 TC2
  9. windows上使用的免费连接linux终端xshell6,xftp6下载
  10. spring学习笔记(五)