把world转成html
2024-08-27 18:55:32
本来用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、怎么显示为手机页呢?这就需要把页面包涵进来,用正则进行处理一下。
最新文章
- 使用visualvm远程监控JVM LINUX服务器配置方法
- JAVA用途
- iOS学习之单例模式
- highcharts 不显示X轴 Y轴 刻度
- eclispe常用快捷键
- R之data.table -melt/dcast(数据合并和拆分)
- Android-MediaProvider数据库模式
- Integrating JAD decompiler into JDeveloper(转)
- 每日一九度之 题目1040:Prime Number
- YARN应用程序的开发步骤
- #ifdef __cplusplus extern c #endif 的作用
- sqlplus乱码
- 一个经试用效果非常不错的数据库连接池--JAVA
- differ比较两个字符串的差异
- watch命令
- TypeScript教程2
- 给指针malloc分配空间后就等于数组吗?【转】
- 汇编指令-CMP、TEQ(5)
- Velocity(2)——常用语法
- Spring MVC 集成Disconf
热门文章
- React Conf 2017 干货总结 1: React + ES next = ♥
- TELNET终端类型选项
- sqlmap批量扫描burpsuite拦截的日志记录
- python--如何操作表
- centos7 minimal connect: Network is unreachable(转)
- PHP+MYSQL的搭建
- hibernate学习系列-----(8)hibernate对集合属性的操作之Collectioon集合篇
- 倍福TwinCAT(贝福Beckhoff)常见问题(FAQ)-如何配置虚拟轴 TC2
- windows上使用的免费连接linux终端xshell6,xftp6下载
- spring学习笔记(五)