import com.jacob.com.*;
import com.jacob.activeX.*;
import java.io.*;
public class Wordtojsp {
public static void change(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文件名
System.out.println(filename.substring(0, (filename.length() - 4)));
ActiveXComponent app = new ActiveXComponent("Word.Application");//启动word
String docpath = paths + filename;
String htmlpath = savepaths + filename.substring(0, (filename.length() - 4));
String inFile = docpath;
//要转换的word文件
String tpFile = htmlpath;
//HTML文件
boolean flag = false;
try{
app.setProperty("Visible", new Variant(false));
//设置word不可见
Dispatch docs = app.getProperty("Documents").toDispatch();
Dispatch doc = Dispatch.invoke(docs,"Open", Dispatch.Method, new Object[]{inFile,new Variant(false), new Variant(true)}, new int[1]).toDispatch();
//打开word文件
Dispatch.invoke(doc,"SaveAs", Dispatch.Method, new Object[]{tpFile,new Variant(8)}, new int[1]);
//作为html格式保存到临时文件
Variant f = new Variant(false);
Dispatch.call(doc, "Close", f);
flag = true;
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
app.invoke("Quit", new Variant[] {});
}
System.out.println("转化完毕!");
}
}
else
{
pathss = paths;
//进入下一级目录
pathss = pathss + lists[i].getName() + "\\";
//递归遍历所有目录
change(pathss,savepaths);
}
}
}
public static void main(String[] args)
{
String paths = new String("D:\\aa\\");
String savepaths = new String ("D:\\aa\\");
change(paths,savepaths);
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
wordtojsp(java)
共15个文件
dll:6个
prefs:4个
class:1个
4星 · 超过85%的资源 需积分: 10 9 下载量 148 浏览量
2012-11-14
16:13:54
上传
评论
收藏 183KB RAR 举报
温馨提示
用java开发的word to jsp程序包,能把word转换成jsp文件
资源推荐
资源详情
资源评论
收起资源包目录
wordtojsp.rar (15个子文件)
wordtojsp
gluegen-rt.dll 20KB
src
Wordtojsp.java 2KB
jogl_cg.dll 112KB
bin
Wordtojsp.class 3KB
.classpath 374B
.settings
com.genuitec.jboss.ide.eclipse.xdoclet.run.prefs 120B
org.eclipse.core.resources.prefs 88B
org.eclipse.jdt.core.prefs 629B
org.eclipse.ltk.core.refactoring.prefs 137B
jacob-1.17-M2-x64.dll 213KB
.project 385B
jogl.dll 308KB
jacob-1.17-M2-x86.dll 172KB
jogl_awt.dll 20KB
.myumldata 66B
共 15 条
- 1
资源评论
- kangqian992013-08-26不错 这个程序可以跑起来
pjf
- 粉丝: 1
- 资源: 7
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功