jacob简单调用word,execl(二)
来源:互联网 发布:淘宝网怎么开店 编辑:程序博客网 时间:2024/06/03 08:48
1,jacob调用word
public static void main(String [] args){String paths = new String("e:\\xjy\\jcob-test\\temp\\");String savePaths = new String("e:\\xjy\\jcob-test\\newTemp\\");change(paths,savePaths);}/** * 将word文档转换成HTML文档 * @author * @version V1.0 * @param paths * @param savePaths*/public static void change(String paths ,String savePaths){File file = new File(paths);File lists[] = file.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());if(fileType.equals("doc")){System.out.println(paths);System.out.println(fileName.substring(0, (fileName.length()-4)));ActiveXComponent app = new ActiveXComponent("Word.Application");String docPath = paths + fileName;String htmlPath = savePaths + fileName.substring(0, fileName.length()-4);String inFile = paths + "\\" + fileName;String tpFile = htmlPath ;boolean flag = false;try{app.setProperty("Visible", new Variant(false));Object docs = app.getProperty("Documents").toDispatch();Object doc = Dispatch.invoke((Dispatch) docs, "Open", Dispatch.Method, new Object[]{inFile}, new int[1]).toDispatch();System.out.println(tpFile);Dispatch.invoke((Dispatch)doc, "SaveAs", Dispatch.Method, new Object[]{tpFile,new Variant(8)}, new int[1]);Variant f = new Variant(false);Dispatch.invoke((Dispatch)doc, "Close", Dispatch.Method, new Object[]{new Variant(false)}, new int[1]);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);}}}
这个是网上找的例子,已经测试成功。
2,jacob调用execl
public static void main(String[] args) { ActiveXComponent xl = new ActiveXComponent("Excel.Application"); Dispatch xlo = (Dispatch) (xl.getObject()); try { System.out.println("version=" + xl.getProperty("Version")); System.out.println("version=" + Dispatch.get(xlo, "Version")); } catch (Exception e) { e.printStackTrace(); } finally { xl.invoke("Quit", new Variant[] {}); } }
3,jacob调用系统声音
public static void main(String[] args) {ActiveXComponent sap = new ActiveXComponent("SAPI.SpLexicon.1");Dispatch sapo = sap.getObject();boolean flag = false;try {// 调整音量和读的速度sap.setProperty("Volume", new Variant(100));sap.setProperty("Rate", new Variant(0));// 这一句是读出来abc这三个字母的Dispatch.call(sapo, "Speak", new Variant("abc"));flag = true;} catch (Exception e) {flag = false;e.printStackTrace();} finally {if (flag) {System.out.println("Over!");} elseSystem.out.println("Application end with exception!");}}未成功。…………
- jacob简单调用word,execl(二)
- java jacob word (二)
- JAVA操作Word(jacob调用com)
- JACOB调用WORD宏
- jacob调用word方法
- java通过jacob调用word
- java通过jacob调用word
- Jacob调用打印机打印Word
- java jacob word 之二
- java中通过jacob调用word方法
- jacob调用(一)
- java jacob word (一)
- java jacob word (三)
- jacob操作office word简单教程
- 利用模板导出文件(二)之jacob利用word模板导出word文件(Java2word)
- 使用Jacob调用word将word转换为html
- Jacob操作word(基础操作)
- java操作word文档(jacob,poi)
- oracle游标
- 知识记录:string、wstring、cstring、 char、 tchar、int、dword转换方法
- 字符,字节和编码
- C++中的静态变量和函数
- shell之文本过滤(正则表达式)
- jacob简单调用word,execl(二)
- 编程: 给定一个存放整数的数组,重新排列数组使得数组左边为奇数,右边为偶数。
- 关于我做openstack的报告的ppt分享
- nginx源码分析(1)- 缘起
- yed软件使用
- JAVA设计模式之工厂模式
- 数组和指针的关系
- eclipse下直接查看jar, jadclipse安装下载 反编译.class文件
- SVM入门(九)松弛变量(续)