jacob 问题

cb1156 2008-02-27 01:43:29
要用JAVA做个 把WORD 的东西转成HTML 的
上网搜了下,代码有人写好了
可是要用到 JACOB 包, 编译没问题,运行总是报错。
找了很久,有人说是 JACOB.DLL 的版本问题
据说要用 YAHOO 的 JACOB 讨论组里的,可是那个组已经不存在了。
所以我想降低JDK的版本。 从1.5换到1.42了。。 我找不到1.31 哪有下的。。
求解。。。。

最好是哪位高人有 YAHOO JACOB讨论组里的那个JACOB.DLL
caballe8226@gmail.com 麻烦发到我邮箱吧。。
如果有JDK1.31也麻烦发下
拜托了。。。
...全文
252 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
cb1156 2008-02-28
  • 打赏
  • 举报
回复
结了吧 我决定换POI做了...
刚刚收到消息.. 要在 LINUX 下
cb1156 2008-02-28
  • 打赏
  • 举报
回复
图片也要能提出来.....
跪求....
cb1156 2008-02-28
  • 打赏
  • 举报
回复
谁能给个 POI操作DOC 并且能读出里面字体格式 的 例子
给完结帖了~
cb1156 2008-02-28
  • 打赏
  • 举报
回复
package testh;

import java.io.*;
import org.textmining.text.extraction.WordExtractor;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFCell;





public class testcls {

public static void readdoc(String paths, String savepaths)
{
File d = new File(paths);
//取得当前文件夹下所有文件和目录的列表
File lists[] = d.listFiles();
String pathss = new String("");

//对当前目录下面所有文件进行检索
for(int i = 0; i < lists.length; i ++)
{
if(lists[i].isFile())
{
String filename = lists[i].getName();
String filetype = new String("");
//取得文件类型
filetype = filename.substring((filename.length() - 3), filename.length());

//判断是否为doc文件
if(filetype.equals("doc"))
{
System.out.println("当前正在检索....");
//打印当前目录路径
System.out.println(paths);
//打印doc文件名
String fname=filename.substring(0, (filename.length() - 4));
System.out.println(fname);
try
{
//打印文件内容
FileInputStream in = new FileInputStream(paths+fname+".doc");
WordExtractor extractor = new WordExtractor();
String str = extractor.extractText(in);
//System.out.println("the result length is"+str.length());
System.out.println(str);



BufferedReader bufread;
//指定文件路径和名称
String path = savepaths+fname+".html";
File outfilename = new File(path);
String readStr ="";


/** *//**
* 创建文本文件.
* @throws IOException
*
*/

if (!outfilename.exists()) {
outfilename.createNewFile();
System.err.println(outfilename + "已创建!");

}
else
{
System.out.print("文件已存在,放弃创建,请处理存在文件后再运行...\n");
continue;
}


String filein =str;
RandomAccessFile mm = null;
try {

FileOutputStream out=new FileOutputStream(paths+fname+".html",true);

StringBuffer sb=new StringBuffer();
sb.append(filein);
out.write(sb.toString().getBytes("utf-8"));



} catch (IOException e1) {
// TODO 自动生成 catch 块
e1.printStackTrace();
} finally {
if (mm != null) {
try {
mm.close();
} catch (IOException e2) {
// TODO 自动生成 catch 块
e2.printStackTrace();
}
}
}

}
catch(Exception e)
{
e.printStackTrace();
}
}

}

}

}


public static void main(String args[]) throws Exception
{
String paths = new String("c:\\a\\");
String savepaths = new String ("c:\\a\\");
readdoc(paths,savepaths);

}


}

POI 0.4 下载地址 http://pickup.mofile.com/3190356099200257

主要解决这个包的org.textmining.text.extraction.WordExtractor;
另外大概还要下个 3.0.2 大家去搜下吧. 上面这个不好找 给出来
以上方法不能保留字体格式和图片... 我再去研究
cb1156 2008-02-27
  • 打赏
  • 举报
回复
POI 是可以操作。。
不过我不知道POI 怎么转存为HTML.
yangxiao_jiang 2008-02-27
  • 打赏
  • 举报
回复
POI我记得是可以操作word的,你去看看吧.apache的.
cb1156 2008-02-27
  • 打赏
  • 举报
回复
能麻烦具体点么 。。。
要实现 批量 WORD转 HTML。。。。
ganghua 2008-02-27
  • 打赏
  • 举报
回复
jacob 是 Java-COM 桥,即是从java中访问COM/DCOM组件,所以,你需要知道如何用word.dll才可以。我记着有其他得解决方案,好像是apach的一个开源项目。
cb1156 2008-02-27
  • 打赏
  • 举报
回复
或者哪位高人告诉我 JDK 1.5
JACOB 1.6-1.14
下的解决办法。。。。

62,623

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧