谁有jacob1.9 64位 下载.jar 1.9的开发包

> Jacob学习心得(1)
Jacob学习心得(1)
yasebaby & &
发布时间: & &
浏览:109 & &
回复:0 & &
悬赏:0.0希赛币
Jacob学习心得(一)
  最近项目中要实现读写word文件,于是偶就开始在网上和群里查询和询问,终于找到了个叫做Jacob的组件可以搞定这个问题。
  第一步,下载Jacob;地址为:
  目前最新的版本为jacob-1.15-M4
  第二步,部署Jacob;
  a。在Eclipse或Myeclipse中建立一个项目(web或普通的java项目都可):JacobDemo;
  b。将下载好的jacob-1.15-M4.zip解压,将jacob.jar导入新建立的项目中;
  c。将jacob-1.15-M4-x86.dll或jacob-1.15-M4-x64.dll拷贝到C:\WINDOWS\system32,由于我的电脑比较老所以我拷贝的是jacob-1.15-M4-x86.dll。
  第三步,在新建立的项目中建立测试类:WordOperate.java,该文件是我在网上拷贝的,特此声明。
  import com.jacob.activeX.ActiveXC
import co.D
import co.V
public class WordOperate {
public static void main(String args[]) {
ActiveXComponent wordApp = new ActiveXComponent("Word.Application"); // 启动word
// Set the visible property as required.
Dispatch.put(wordApp, "Visible", new Variant(true));// //设置word可见
Dispatch docs = wordApp.getProperty("Documents").toDispatch();
// String inFile = "d:\\test.doc";
// Dispatch doc = Dispatch.invoke(docs, "Open", Dispatch.Method,
// new Object[] { inFile, new Variant(false), new Variant(false)},//参数3,false:可写,true:只读
// new int[1]).toDispatch();//打开文档
Dispatch document = Dispatch.call(docs, "Add").toDispatch();// create new document
//String userName = wordApp.getPropertyAsString("Username");// 显示用户信息
/*String userName = wordApp.getProperty("Username");// 显示用户信息
System.out.println("用户名:" + userName);*/
// 文档对齐,字体设置////////////////////////
Dispatch selection = Dispatch.get(wordApp, "Selection").toDispatch();
Dispatch align = Dispatch.get(selection, "ParagraphFormat")
.toDispatch(); // 行列格式化需要的对象
Dispatch font = Dispatch.get(selection, "Font").toDispatch(); // 字型格式化需要的对象
// 标题处理////////////////////////
Dispatch.put(align, "Alignment", "1"); // 1:置中 2:靠右 3:靠左
Dispatch.put(font, "Bold", "1"); // 字型租体
Dispatch.put(font, "Color", "1,0,0,0"); // 字型颜色红色
Dispatch.call(selection, "TypeText", "Word文档处理"); // 写入标题内容
Dispatch.call(selection, "TypeParagraph"); // 空一行段落
Dispatch.put(align, "Alignment", "3"); // 1:置中 2:靠右 3:靠左
Dispatch.put(selection, "Text", "
Dispatch.call(selection, "MoveDown"); // 光标标往下一行
//表格处理////////////////////////
Dispatch tables = Dispatch.get(document, "Tables").toDispatch();
Dispatch range = Dispatch.get(selection, "Range").toDispatch();
Dispatch table1 = Dispatch.call(tables, "Add", range, new Variant(3),
new Variant(2), new Variant(1)).toDispatch(); // 设置行数,列数,表格外框宽度
// 所有表格
Variant tableAmount = Dispatch.get(tables, "count");
System.out.println(tableAmount);
// 要填充的表格
Dispatch t1 = Dispatch.call(tables, "Item", new Variant(1))
.toDispatch();
Dispatch t1_row = Dispatch.get(t1, "rows").toDispatch();// 所有行
int t1_rowNum = Dispatch.get(t1_row, "count").getInt();
Dispatch.call(Dispatch.get(t1, "columns").toDispatch(), "AutoFit");// 自动调整
int t1_colNum = Dispatch.get(Dispatch.get(t1, "columns").toDispatch(),
"count").getInt();
System.out.println(t1_rowNum + " " + t1_colNum);
for (int i = 1; i &= t1_rowN i++) {
for (int j = 1; j &= t1_colN j++) {
Dispatch cell = Dispatch.call(t1, "Cell", new Variant(i),
new Variant(j)).toDispatch();// 行,列
Dispatch.call(cell, "Select");
Dispatch.put(selection, "Text", "cell" + i + j); // 写入word的内容
Dispatch.put(font, "Bold", "0"); // 字型租体(1:租体 0:取消租体)
Dispatch.put(font, "Color", "1,1,1,0"); // 字型颜色
Dispatch.put(font, "Italic", "1"); // 斜体 1:斜体 0:取消斜体
Dispatch.put(font, "Underline", "1"); // 下划线
Dispatch Range = Dispatch.get(cell, "Range").toDispatch();
String cellContent = Dispatch.get(Range, "Text").toString();
System.out.println((cellContent.substring(0, cellContent
.length() - 1)).trim());
Dispatch.call(selection, "MoveDown"); // 光标往下一行(才不会输入盖过上一输入位置)
//合并单元格////////////////////////
Dispatch.put(selection, "Text", "
Dispatch.call(selection, "MoveDown"); // 光标标往下一行
Dispatch range2 = Dispatch.get(selection, "Range").toDispatch();
Dispatch table2 = Dispatch.call(tables, "Add", range2, new Variant(8),
new Variant(4), new Variant(1)).toDispatch(); // 设置行数,列数,表格外框宽度
Dispatch t2 = Dispatch.call(tables, "Item", new Variant(2))
.toDispatch();
Dispatch beginCell = Dispatch.call(t2, "Cell", new Variant(1),
new Variant(1)).toDispatch();
Dispatch endCell = Dispatch.call(t2, "Cell", new Variant(4),
new Variant(4)).toDispatch();
Dispatch.call(beginCell, "Merge", endCell);
for (int row = 1; row &= Dispatch.get(
Dispatch.get(t2, "rows").toDispatch(), "count").getInt(); row++) {
for (int col = 1; col &= Dispatch.get(
Dispatch.get(t2, "columns").toDispatch(), "count").getInt(); col++) {
if (row == 1) {
Dispatch cell = Dispatch.call(t2, "Cell", new Variant(1),
new Variant(1)).toDispatch();// 行,列
Dispatch.call(cell, "Select");
Dispatch.put(font, "Color", "1,1,1,0"); // 字型颜色
Dispatch.put(selection, "Text", "merge Cell!");
Dispatch cell = Dispatch.call(t2, "Cell", new Variant(row),
new Variant(col)).toDispatch();// 行,列
Dispatch.call(cell, "Select");
Dispatch.put(font, "Color", "1,1,1,0"); // 字型颜色
Dispatch.put(selection, "Text", "cell" + row + col);
Dispatch.call(selection, "MoveDown");
//Dispatch.call(selection, "MoveRight", new Variant(1), new Variant(1));// 取消选择
// Object content = Dispatch.get(doc,"Content").toDispatch();
// Word文档内容查找及替换////////////////////////
Dispatch.call(selection, "TypeParagraph"); // 空一行段落
Dispatch.put(align, "Alignment", "3"); // 1:置中 2:靠右 3:靠左
Dispatch.put(font, "Color", 0);
Dispatch.put(selection, "Text", "欢迎,Hello,world!");
Dispatch.call(selection, "HomeKey", new Variant(6));// 移到开头
Dispatch find = Dispatch.call(selection, "Find").toDispatch();// 获得Find组件
Dispatch.put(find, "Text", "hello"); // 查找字符串"hello"
Dispatch.put(find, "Forward", "True");// 向前查找
// Dispatch.put(find, "Format", "True");// 设置格式
Dispatch.put(find, "MatchCase", "false");// 大小写匹配
Dispatch.put(find, "MatchWholeWord", "True"); // 全字匹配
Dispatch.call(find, "Execute"); // 执行查询
Dispatch.put(selection, "Text", "你好");// 替换为"你好"
//使用方法传入的参数parameter调用word文档中的MyWordMacro宏//
//Dispatch.call(document,macroName,parameter);
//Dispatch.invoke(document,macroName,Dispatch.Method,parameter,new int[1]);
//页眉,页脚处理////////////////////////
Dispatch ActiveWindow = wordApp.getProperty("ActiveWindow")
.toDispatch();
Dispatch ActivePane = Dispatch.get(ActiveWindow, "ActivePane")
.toDispatch();
Dispatch View = Dispatch.get(ActivePane, "View").toDispatch();
Dispatch.put(View, "SeekView", "9"); //9是设置页眉
Dispatch.put(align, "Alignment", "1"); // 置中
Dispatch.put(selection, "Text", "这里是页眉"); // 初始化时间
Dispatch.put(View, "SeekView", "10"); // 10是设置页脚
Dispatch.put(align, "Alignment", "2"); // 靠右
Dispatch.put(selection, "Text", "这里是页脚"); // 初始化从1开始
//书签处理(打开文档时处理)////////////////////////
//Dispatch activeDocument = wordApp.getProperty("ActiveDocument").toDispatch();
Dispatch bookMarks = Dispatch.call(document, "Bookmarks").toDispatch();
boolean isExist = Dispatch.call(bookMarks, "Exists", "bookMark1")
.getBoolean();
if (isExist == true) {
Dispatch rangeItem1 = Dispatch.call(bookMarks, "Item", "bookMark1")
.toDispatch();
Dispatch range1 = Dispatch.call(rangeItem1, "Range").toDispatch();
Dispatch.put(range1, "Text", new Variant("当前是书签1的文本信息!"));
String bookMark1Value = Dispatch.get(range1, "Text").toString();
System.out.println(bookMark1Value);
System.out.println("当前书签不存在,重新建立!");
Dispatch.call(bookMarks, "Add", "bookMark1", selection);
Dispatch rangeItem1 = Dispatch.call(bookMarks, "Item", "bookMark1")
.toDispatch();
Dispatch range1 = Dispatch.call(rangeItem1, "Range").toDispatch();
Dispatch.put(range1, "Text", new Variant("当前是书签1的文本信息!"));
String bookMark1Value = Dispatch.get(range1, "Text").toString();
System.out.println(bookMark1Value);
//保存操作////////////////////////
Dispatch.call(document, "SaveAs", "D:/wordOperate.doc");
//Dispatch.invoke((Dispatch) doc, "SaveAs", Dispatch.Method, new Object[]{htmlPath, new Variant(8)}, new int[1]);
//生成html文件
// 0 = wdDoNotSaveChanges
// -1 = wdSaveChanges
// -2 = wdPromptToSaveChanges
//Dispatch.call(document, "Close", new Variant(0));
// // worddoc.olefunction("protect",2,true,"");
// // Dispatch bookMarks = wordApp.call(docs,"Bookmarks").toDispatch();
// // System.out.println("bookmarks"+bookMarks.getProgramId());
// //Dispatch.call(doc, "Save"); //保存
// // Dispatch.call(doc, "Close", new Variant(true));
// //wordApp.invoke("Quit",new Variant[]{});
// wordApp.safeRelease();//Finalizers call this method
  运行即可看到效果,需要说明的是你的电脑上要安装好word。
  异常处理:
  如果在运行过程中遇到[JACOB] ------&no jacob in the java.library.path异常,请尝试将 jacob.dll放到System.getProperty("java.library.path")取到的目录下。
本问题标题:
本问题地址:
温馨提示:本问题已经关闭,不能解答。
暂无合适的专家
&&&&&&&&&&&&&&&
希赛网 版权所有 & &&&&&&jacob 1.15、1.16、1.17、1.9 jar包和动态库
jacob 1.15、1.16、1.17、1.9 jar包和动态库
jacob相关jar包和动态库,jacob1.15,jacob1.16,jacob1.17和jacob1.9
若举报审核通过,可奖励20下载分
被举报人:
举报的资源分:
请选择类型
资源无法下载
资源无法使用
标题与实际内容不符
含有危害国家安全内容
含有反动色情等内容
含广告内容
版权问题,侵犯个人或公司的版权
*详细原因:
VIP下载&&免积分60元/年(1200次)
您可能还需要
开发技术下载排行MenuDownload jacob-1.14.3.jar : jacob&&&j&&&Jar File DownloadDownload jacob-1.14.3.jar
Files contained in jacob-1.14.3.jar:
META-INF/JacobVersion.properties
META-INF/MANIFEST.MF
com.jacob.activeX.ActiveXComponent.class
com.jacob.activeX.ActiveXDispatchEvents.class
com.jacob.activeX.ActiveXInvocationProxy.class
.ComException.class
.ComFailException.class
.ComThread.class
.Currency.class
.DateUtilities.class
.Dispatch.class
.DispatchEvents.class
.DispatchIdentifier.class
.DispatchNullProgramId.class
.DispatchProxy.class
.EnumVariant.class
.InvocationProxy.class
.InvocationProxyAllVariants.class
.JacobException.class
.JacobObject.class
.JacobReleaseInfo.class
.LibraryLoader.class
.MainSTA.class
.NotImplementedException.class
.ROT.class
.STA.class
.SafeArray.class
.Variant.class
.VariantUtilities.class
.VariantViaEvent.class
.WrongThreadException.class
Related examples in the same category1.
&|&Email:info &|&& Demo Source and Support. All rights reserved.jacob-1.18-M1调用通信插件成功总结
1、下载插件jacob-1.18-M1
2、将jacob.jar放到webroot/lib/下
将jacob-1.18-M1-x86.dll放到windows/system32/下,如果还不行同时将其放到tomcat/bin下,如果不放就会报错如下,还要用网页将插件加载一遍,否则插件注册不上。
第一种情况
& Exception in thread "main"
java.lang.UnsatisfiedLinkError: no jacob-1.18-M1-x86 in
java.library.path
java.lang.ClassLoader.loadLibrary(ClassLoader.java:1709)
java.lang.Runtime.loadLibrary0(Runtime.java:823)
java.lang.System.loadLibrary(System.java:1030)
.LibraryLoader.loadJacobLibrary(LibraryLoader.java:184)
.JacobObject.(JacobObject.java:107)
.LibraryLoader.loadJacobLibrary(LibraryLoader.java:181)
.ComThread.(ComThread.java:167)
com.jacob.service.collectdata.(collectdata.java:13)
com.jacob.service.collectdata.main(collectdata.java:53)
ERROR: JDWP Unable to get JNI 1.2 environment, jvm-&GetEnv()
return code = -2
JDWP exit error AGENT_ERROR_NO_JNI_ENV(183):&
[../../../src/share/back/util.c:820]
第二种情况
& Exception in thread "main"
java.lang.UnsatisfiedLinkError: no jacob-1.18-M1-x86 in
java.library.path
java.lang.ClassLoader.loadLibrary(ClassLoader.java:1709)
java.lang.Runtime.loadLibrary0(Runtime.java:823)
java.lang.System.loadLibrary(System.java:1030)
.LibraryLoader.loadJacobLibrary(LibraryLoader.java:184)
.JacobObject.(JacobObject.java:107)
.LibraryLoader.loadJacobLibrary(LibraryLoader.java:181)
.ComThread.(ComThread.java:167)
com.jacob.service.collectdata.(collectdata.java:13)
com.jacob.service.collectdata.main(collectdata.java:53)
3、完成以上两步可以根据jacob接口函数写功能实现:例如
public& collectdata() {
&&ComThread.InitMTA(true);
&&ActiveXComponent iTunesCom =
ActiveXComponent("clsid:5B43E1EB-59DA-4F16-9D09-018B24063F56");
&&Dispatch testOcx =
(Dispatch)iTunesCom.getObject();
String xml="root8.0.71";
&&//Dispatch.call(testOcx,
"SendCmdString",new Variant(xml));
//Variant v=new Variant(xml);
//ResponseView se = new ResponseView();&
//DispatchEvents de = new
DispatchEvents(testOcx,se,"clsid:5B43E1EB-59DA-4F16-9D09-018B24063F56");&&
//ActiveXDispatchEvents events = new
ActiveXDispatchEvents(testOcx,se,"clsid:5B43E1EB-59DA-4F16-9D09-018B24063F56");
Variant result =Dispatch.call(testOcx, "SendCmdString", new
Variant(xml));
&&System.out.print("aa");
&&} catch (ComException e)
e.printStackTrace();
&&ComThread.Release();
&&//System.exit(0);
以上网友发言只代表其个人观点,不代表新浪网的观点或立场。}

我要回帖

更多关于 jacob1.9 64位 dll 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信