易截截图软件、单文件、免安装、纯绿色、仅160KB

java把word转html或txt

最近项目中需要在页面中预览word文件,虽说word本身就可以在页面中打开,但是有两个弊端,1是可客户端必须安装word, 2是客户端的环境以及office版本有差异,会造成预览不稳定。在网上找了一下,发现poi可以把word装换成txt,但是格式都丢了,只有光秃秃的文本,又搜jacob, 网友们众说纷纭, 最后还是自己sourceforge上下载jacob并阅读doc搞定了.
1 goto http://sourceforge.net/projects/jacob-project/ and download latest library of jacob.
下载的zip文件结构如下:
2 intel cpu的机器拷贝jacob-1.15-M3-x86.dll到%JAVA_HOME%/jre/bin, AMD cpu的机器拷贝jacob-1.15-M3-x64.dll. 不过请确保jre目录是你正在使用的jre, 因为现在很多eclipse版本自己带jre. 这个在eclipse windows-> preferences -> installed jres可以查看.
3 拷贝jacob.jar到你项目目录的lib下面并确保加入到了classpath.
准备工作完毕, 现在就写程序了.
import com.jacob.activeX.ActiveXComponent;
import com.jacob.com.Dispatch;
import com.jacob.com.Variant;
public class Test {
public static void main(String[] args) {
ActiveXComponent app = new ActiveXComponent("Word.Application");
app.setProperty("Visible", new Variant(false));
Dispatch doc1 = app.getProperty("Documents").toDispatch();
//打开aaaa.doc
Dispatch doc2 = Dispatch.invoke(
doc1,
"Open",
Dispatch.Method,
new Object[]{"e:\\aaaa.doc", new Variant(false), new Variant(true)},
new int[1]
).toDispatch();
//另存为aaaa.html
Dispatch.invoke(
doc2,
"SaveAs",
Dispatch.Method,
new Object[]{
"c:\\aaaa.html",
new Variant(8)//7为txt格式, 8保存为html格式
},
new int[1]
);
Variant f = new Variant(false);
Dispatch.call(doc2, "Close", f);
}
}
使用起来很简单.
当然jacob不光可以做word to html, 还可以做很多事情:
Jacob is a Java library that lets Java applications communicate with Microsoft Windows DLLs or COM libraries. It does this through the use of a custom DLL that the Jacob Java classes communicate with via JNI. The library and dll isolate the Java developer from the underlying windows libraries so that


相关文档:

Java中集合容器类List和Set的用法

List的用法
List包括List接口以及List接口的所有实现类。因为List接口实现了Collection接口,所以List接口拥有Collection接口提供的所有常用方法,又因为List是列表类型,所以List接口还提供了一些适合于自身的常用方法,如表1所示。
表1  List接口定义的常用方法及功能
从表1可以看出,List接口提供的适合于自身的 ......

IBM FileNet Content Java API 简介

2008 年 6 月 24 日
原文地址: http://www.ibm.com/developerworks/cn/data/library/techarticles/dm-0806wangys/
本文介绍 IBM FileNet P8 4.0 Platform 提供的 Content Java API。首先对 FileNet P8 Content Engine 和 API 进行概要介绍, 并说明了一些基本概念,随后详细介绍了 FileNet Content Engine提供的基于 EJB ......

JAVA实现验证码

一、主要功能:

1、支持纯数字、大写字母、小写字母,及两两混合或三者混合类型验证码;
2、支持自定义特殊字符排除(如0oOi1jI);
3、支持图片及文字两种类型验证码;
4、支持自定义验证码图片大小;
5、支持自定义干扰线条数;
6、支持自定义及随机定义图片、文字、干扰线颜色;

......

Java解惑1 3长整数

这个谜题之所以被称为长整除是因为它所涉及的程序是有关两个long型数值整除的。被除数表示的是一天里的微秒数;而除数表示的是一天里的毫秒数。这个程序会打印出什么呢?
public class LongDivision{
public static void main(String args[]){
final long MICROS_PER_DAY = 24 * 60 * 60 * 1000 * 1000;
final lo ......

刚刚找出来的相对准确的查找HTML的正则表达式

Dim objReg,objMatches,objMatch
Set objReg=new RegExp
objReg.Global=True
objReg.IgnoreCase=True
objReg.Pattern="<('[^']*'|""[^""]*""|[^'"">])*?>"
Set objMatches=objReg.Execute(字符串)
For Each objMatch In objMatches
找到的HTML :objMatch.value
Next
Set objMatches=Nothing
Set objRe ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号