JCom可以支持打印,支持生成word,生成Excel,并且可以将文本转换成pdf
这里给出生成word和添加表格的代码:import jp.ne.so_net.ga2.no_ji.jcom.IDispatch;
import jp.ne.so_net.ga2.no_ji.jcom.JComException;
import jp.ne.so_net.ga2.no_ji.jcom.ReleaseManager;
public class TestCreatWord {
/**
* @param filePath --文件的路径
* @param text --插入的文本的内容
* @param fontName --字体的名字
* @param fontSize --字号
* @param fontBold --是否加粗
* @param align --对齐方式:comment--0:left,1:center,2:right
*/
public synchronized void createWord(String filePath, String text,
String fontName, String fontSize, Boolean fontBold, int align) {
ReleaseManager rm = new ReleaseManager();
IDispatch docApp = null;
try {
docApp = new IDispatch(rm, "Word.Application");
IDispatch documents = (IDispatch) docApp.get("Documents");
documents.method("add", null);
IDispatch selection = ((IDispatch) docApp.get("Selection"));
IDispatch paragraphFormat = ((IDispatch) selection
.get("ParagraphFormat"));
paragraphFormat.put("Alignment", new Integer(align));// 对齐方式0:left,1:center,2:right
IDispatch font = ((IDispatch) selection.get("Font"));
font.put("name", fontName);
font.put("Size", fontSize);
font.put("Bold", fontBold);
selection.method("TypeText", new Object[] { text });
((IDispatch) docApp.get("ActiveDocument")).method("saveAs",
new Object[] { filePath, new Integer(0) });
} catch (JComException e) {
e.printStackTrace();
} finally {
try {
if (docApp != null) {
((IDispatch) docApp.get("ActiveDocument")).put("Saved",
new Boolean(true));
docApp.method("quit", null);
docApp = null;
}
rm.release();
rm = null;
} catch (JComException e) {
e.printStackTrace();
}
}
}
/**
* @param filePath --文件路径
* @param rowsNum --行数
* @param colsNum --列数
* @param vals --数组
*/
public synchronized void addTable(String filePath, int rowsNum,
int colsNum, String[][] vals) {
ReleaseManager rm = new ReleaseManager();
IDispatch docApp = null;
try {
docApp = new IDispatch(rm, "Word.Application");
IDispatch documents = (IDispatch) docApp.get("Documents");
IDispatch doc = (IDispatch) documents.method("open",
new Object[] { filePath });// open
IDispatch selection = ((IDispatch) docApp.get("Selection"));
selection.method("endKey", new Object[] { new Integer(6) });// 光标到文档末尾
//selection.method("InsertBreak", new Object[] { new Integer(7) });// 插入一个分页符
IDispatch range = (IDispatch) doc.method("Range", new Object[] {
selection.get("start"), selection.get("start") });// 获得一个range,不知道干什么的
range.method("InsertBreak", new Object[] { new Integer(2) });// 插入一个分页符
selection.put("start", ((Integer) selection.get("start")) + 1);//选取的开始点右移一个位置,不知道为什么,但是不加这一行不行,变成整篇文档横排了
// selection = ((IDispatch) docApp.get("Selection"));
range = (IDispatch) doc.method("Range", new Object[] {
selection.get("start"),
((IDispatch) doc.get("Content")).get("end") });//获得一个范围
IDispatch pageSetup = (IDispatch) range.get("PageSetup");//获得页面设置
pageSetup.put("Orientation", new Integer(1));//横排
IDispatch tables = ((IDispatch) doc.get("Tables"));// 得到doc中的表格集合
tables.method("add", new Object[] { selection.get("range"),
rowsNum, colsNum });// 增加一张表
IDispatch table = (IDispatch) tables.method("item",
new Object[] { new Integer(1) });// 获得刚增加的表格
IDispatch rows = ((IDispatch) table.get("rows"));// 得到行集合
for (int i = 1; i <= rowsNum; i++) {
IDispatch row = (IDispatch) rows.method("item",
new Object[] { new Integer(i) });
IDispatch cells = (IDispatch) row.get("Cells");// 单元格集合
for (int j = 1; j <= colsNum; j++) {
IDispatch cell = (IDispatch) cells.method("item",
new Object[] { new Integer(j) });
((IDispatch) cell.get("Range")).put("Text",
vals[i - 1][j - 1]);//为表格中的格子赋值
}
}
((IDispatch) docApp.get("ActiveDocument")).method("saveAs",
new Object[] { filePath, new Integer(0) });
} catch (JComException e) {
e.printStackTrace();
} finally {
try {
if (docApp != null) {
((IDispatch) docApp.get("ActiveDocument")).put("Saved",
new Boolean(true));
docApp.method("quit", null);
docApp = null;
}
rm.release();
rm = null;
} catch (JComException e) {
e.printStackTrace();
}
}
}
public static void main(String[] args) {
String [][] aa = new String[10][10];
for (int i = 0; i < aa.length; i++)
{
for (int j = 0; j < aa[i].length; j++)
{
aa[i][j] = "empty";
}
}
new TestCreatWord().addTable("c:\\aa.doc", 10, 10, aa) ;
}
}
使用JCom生成Excel
import java.util.Date;
import jp.ne.so_net.ga2.no_ji.jcom.IDispatch;
import jp.ne.so_net.ga2.no_ji.jcom.ReleaseManager;
import jp.ne.so_net.ga2.no_ji.jcom.excel8.ExcelApplication;
import jp.ne.so_net.ga2.no_ji.jcom.excel8.ExcelRange;
import jp.ne.so_net.ga2.no_ji.jcom.excel8.ExcelWorkbook;
import jp.ne.so_net.ga2.no_ji.jcom.excel8.ExcelWorkbooks;
import jp.ne.so_net.ga2.no_ji.jcom.excel8.ExcelWorksheet;
import jp.ne.so_net.ga2.no_ji.jcom.excel8.ExcelWorksheets;
public class TestJcom{
private static ReleaseManager rm = null; // ReleaseManager相当于一个容器,
//与你机器上的所有JCOM组建交互,根据你传的参数他会去寻找你机器上的所有JCOM能操作的组建;
public static void main(String[] args) throws Exception {
rm = new ReleaseManager();//查找JCOM能够操作的组件
IDispatch appl = null;
try {
System.out.println("EXCEL loading...");
ExcelApplication excel = new ExcelApplication(rm);//创建可加载excel组件
excel.Visible(true);//表示显示操作的excel文件
System.out.println("Version=" + excel.Version());
System.out.println("UserName=" + excel.UserName());
System.out.println("Caption=" + excel.Caption());
System.out.println("Value=" + excel.Value());
ExcelWorkbooks xlBooks = excel.Workbooks();//创建工作薄对象
ExcelWorkbook xlBook = xlBooks.Add();//添加工作薄
ExcelWorksheets xlSheets = xlBook.Worksheets();//获得工作薄中的工作表,返回的是以数组形式存放
ExcelWorksheet xlSheet = xlSheets.Item(2);//选中第2个工作表
xlSheet.Name("new sheet name");//修改当前sheet的名字
ExcelRange xlRange = xlSheet.Cells();//得到工作表的单元格
//向指定的单元格中添加值
xlRange.Item(1, 1).Value("第1行,第1列");
xlRange.Item(1, 2).Value("第1行,第2列");
xlRange.Item(1, 3).Value("第1行,第3列");
xlRange.Item(1, 4).Value("第1行,第4列");
xlRange.Item(1, 5).Value("第1行,第5列");
xlRange.Item(1, 6).Value("第1行,第6列");
xlRange.Item(1, 7).Value("第1行,第7列");
File path = new File("c:/");//创建一个文件对象(.表示当前路径下或者使用(./))
String[] filenames = path.list();//列出该文件加下的所有文件
for (int i = 0; i < filenames.length; i++) {
File file = new File(filenames[i]);//得到目录下当前文件对象
System.out.println("file:"+file);//
xlRange.Item(i + 2, 1).Value(file.getName());//文件的名字
xlRange.Item(i + 2, 2).Value((int) file.length());//**返回文件大小**
xlRange.Item(i + 2, 3).Value(new Date(file.lastModified()));//文件最后更新时间
xlRange.Item(i + 2, 4).Value(file.isDirectory() ? "Yes" : "No");//判断是否是目录
xlRange.Item(i + 2, 5).Value(file.isFile() ? "Yes" : "No");//判断是否是文件
xlRange.Item(i + 2, 6).Value(file.canRead() ? "Yes" : "No");//判断是否可写
xlRange.Item(i + 2, 7).Value(file.canWrite() ? "Yes" : "No");//判断是否可读
}
String expression = "=Sum(B2:B" + (filenames.length + 1) + ")";
System.out.println("计算公式:" + expression);
xlRange.Item(filenames.length + 2, 1).Value("大小合计");
xlRange.Item(filenames.length + 2, 2).Formula(expression);//添加使用的表达式
xlRange.Columns().AutoFit();//可以自动调整列宽以适应文字
// xlSheet.PrintOut();//是否打印该文件
xlBook.SaveAs("testExcel3.xls");//保存在上面的目录下
System.out.println("[Enter]");
System.in.read();
xlBook.Close(false, null, false);
excel.Quit();
System.out.println("");
} catch (Exception e) {
e.printStackTrace();
} finally {
rm.release();
}
}
}
用JCOM实现打印如打印word和Excel等的
import jp.ne.so_net.ga2.no_ji.jcom.IDispatch;
import jp.ne.so_net.ga2.no_ji.jcom.JComException;
import jp.ne.so_net.ga2.no_ji.jcom.ReleaseManager;
import jp.ne.so_net.ga2.no_ji.jcom.excel8.ExcelApplication;
import jp.ne.so_net.ga2.no_ji.jcom.excel8.ExcelWorkbook;
import jp.ne.so_net.ga2.no_ji.jcom.excel8.ExcelWorkbooks;
import jp.ne.so_net.ga2.no_ji.jcom.excel8.ExcelWorksheet;
/**
* @author admin
*/
public class TestPrint {
/**
* @param args
* 打印word
*/
public static void main(String[] args) {
TestPrint tp = new TestPrint();
String path="c:\\1111.doc";
tp.print("Word.Application", "Documents", path);
}
/***
* @param docApplication Application类型
* @param docProperty 文档的属性
* @param filePath 文件的绝对路径
*/
public void print(String docApplication,String docProperty,String filePath){
ReleaseManager rm = new ReleaseManager();
try {
IDispatch docApp = new IDispatch(rm, docApplication);
docApp.put("Visible", new Boolean(false));
IDispatch wdDocuments = (IDispatch) docApp.get(docProperty);
Object[] arglist1 = new Object[1];
arglist1[0] = (Object)filePath;
IDispatch docDocument = (IDispatch) wdDocuments.method("Open",
arglist1);
docDocument.method("PrintOut", null);
docApp.method("Quit", null);
}catch(JComException e){
e.printStackTrace();
}
rm.release();
rm = null;
}
/**
* @param fname 文件的路径名称
* @return
*/
public boolean printExcel(String fname) {
ReleaseManager rm = new ReleaseManager();
try {
ExcelApplication excel = new ExcelApplication(rm);
ExcelWorkbooks xlBooks = excel.Workbooks();
ExcelWorkbook xlBook = xlBooks.Open(fname);
ExcelWorksheet xlSheet = excel.ActiveSheet();
xlSheet.PrintOut();
xlBook.Close(false, null, false);
excel.Quit();
} catch (Exception e) {
e.printStackTrace();
return false;
} finally {
rm.release();
}
return true;
}
}
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import jp.ne.so_net.ga2.no_ji.jcom.IDispatch;
import jp.ne.so_net.ga2.no_ji.jcom.JComException;
import jp.ne.so_net.ga2.no_ji.jcom.ReleaseManager;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFFooter;
import org.apache.poi.hssf.usermodel.HSSFHeader;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import com.lccert.crm.project.ChemProject;
import com.lccert.crm.project.ProjectAction;
/**
* 打印流转单类
* @author eason
*
*/
public class PrintFlowAction {
private static PrintFlowAction instance = null;
private PrintFlowAction() {
}
public static PrintFlowAction getInstance() {
if (instance == null) {
instance = new PrintFlowAction();
}
return instance;
}
/**
* 打印流转单
* @param flowfile
* @param flow
* @return
*/
public synchronized boolean Printflow(String flowfile,Flow flow) {
POIFSFileSystem fs = null;
HSSFWorkbook wb = null;
FileOutputStream fileOut = null;
boolean isok = false;
ChemProject cp = ProjectAction.getInstance().getProjectByRid(flow.getRid());
try {
// 读取文件内容
fs = new POIFSFileSystem(new FileInputStream(flowfile));
wb = new HSSFWorkbook(fs);
HSSFSheet sheet = wb.getSheetAt(0);
HSSFRow row = sheet.getRow(1);
HSSFCell cell = row.getCell((short) 1);
if (cell == null)
cell = row.createCell((short) 1);
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
cell.setCellValue(flow.getRid());
cell = row.getCell((short) 5);
if (cell == null)
cell = row.createCell((short) 5);
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
cell.setCellValue(flow.getPid());
row = sheet.getRow(3);
cell = row.getCell((short) 1);
if (cell == null)
cell = row.createCell((short) 1);
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
cell.setCellValue(flow.getPdtime());
cell = row.getCell((short) 5);
if (cell == null)
cell = row.createCell((short) 5);
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
cell.setCellValue(cp.getRptime());
row = sheet.getRow(5);
cell = row.getCell((short) 1);
if (cell == null)
cell = row.createCell((short) 1);
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
cell.setCellValue(cp.getLevel());
cell = row.getCell((short) 5);
if (cell == null)
cell = row.createCell((short) 5);
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
cell.setCellValue(cp.getRptype());
row = sheet.getRow(7);
cell = row.getCell((short) 0);
if (cell == null)
cell = row.createCell((short) 0);
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
cell.setCellValue(flow.getTestparent());
row = sheet.getRow(12);
cell = row.getCell((short) 0);
if (cell == null)
cell = row.createCell((short) 0);
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
cell.setCellValue(flow.getTestchild());
row = sheet.getRow(21);
cell = row.getCell((short) 0);
if (cell == null)
cell = row.createCell((short) 0);
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
cell.setCellValue(cp.getSampledesc());
row = sheet.getRow(34);
cell = row.getCell((short) 0);
if (cell == null)
cell = row.createCell((short) 0);
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
cell.setCellValue(cp.getAppform());
row = sheet.getRow(45);
cell = row.getCell((short) 4);
if (cell == null)
cell = row.createCell((short) 4);
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
cell.setCellValue(new SimpleDateFormat("yyyy-MM-dd").format(flow.getPdtime()));
String icode = "*" + flow.getRid().substring(4,12) + "*";
HSSFHeader header = sheet.getHeader();
header.setCenter(HSSFHeader.fontSize((short) 28)
+ HSSFHeader.font("C39HrP24DmTt", "Normal") + icode);
header.setLeft(HSSFHeader.fontSize((short) 24)
+ HSSFHeader.font("宋体", "常规") + "LC-WS-003" + flow.getFlowtype().substring(0,2));
HSSFFooter footer = sheet.getFooter();
footer.setLeft(new SimpleDateFormat("yyyy-MM-dd").format(new Date()));
footer.setRight("共1页,第1页");
// 把内容写入文件
fileOut = new FileOutputStream(flowfile);
wb.write(fileOut);
fileOut.close();
} catch (Exception e) {
e.printStackTrace();
}
//String path="D:\\test.doc";
//print("Word.Application", "Documents", path);
if(print("Excel.Application", "Workbooks", flowfile)) {
isok = true;
}
return isok;
}
/***
*
* @param docApplication Application类型
* @param docProperty 文档的属性
* @param filePath 文件的绝对路径
*/
private boolean print(String docApplication,String docProperty,String filePath){
ReleaseManager rm = new ReleaseManager();
boolean isok = false;
try {
IDispatch docApp = new IDispatch(rm, docApplication);
docApp.put("Visible", new Boolean(false));
IDispatch wdDocuments = (IDispatch) docApp.get(docProperty);
Object[] arglist1 = new Object[1];
arglist1[0] = (Object)filePath;
IDispatch docDocument = (IDispatch) wdDocuments.method("Open",
arglist1);
docDocument.method("PrintOut", null);
docApp.method("Quit", null);
isok = true;
}catch(JComException e){
e.printStackTrace();
} finally {
rm.release();
rm = null;
}
return isok;
}
}
发表评论
-
nginx代理IIS轻松实现支持JSP,PHP,ASP平台
2012-05-12 21:16 1626通过使用高效代理服务器nginx代理IIS轻松实现支持JSP, ... -
OpenSessionInViewFilter的使用
2011-06-22 11:34 735一、作用 Spring为我们解决Hibernate的Sess ... -
tomcat服务器使用url rewrite1
2011-05-19 18:25 1481让tomcat服务器使用url rewrite1. 第 ... -
CountDownLatch闭锁详解
2011-05-09 10:29 1321闭锁(Latch) 闭锁(Latch):一种同步方法,可以延 ... -
memcache/memcached/memcachedb 配置、安装
2011-05-05 15:44 1206memcache/memcached/memcachedb ... -
jquery.treeview使用
2011-03-25 18:31 1535这几天项目中要用到树型结构,正好项目中用到了JQuery,所以 ... -
集群的可扩展性及其分布式体系结构
2011-03-17 14:54 1107常见的平衡算法 一般 ... -
strust2防止重复提交
2011-03-15 10:05 1130在请求表单中添加<s:token></s:t ... -
源码中没有任何错误目录中还存在红叉
2011-02-26 17:04 773查看.classpath文件。修改正确配置!lib与src -
长连接与短连接
2011-01-04 15:44 1118长连接与短连接 所谓长连接,指在一个TCP连接上可以连续发送 ... -
带“+”号的参数值通过url传递,后台取不到正确值
2010-11-29 15:19 2485带“+”号的参数值通过url传递,后台取不到正确值 问题是这样 ... -
利用java操作Excel文件
2010-10-28 16:45 752利用java操作Excel文件 很久以来都想 ... -
XSL将XML转换成HTML文件 js方法
2010-10-22 14:34 3019JavaScript解决方案XSL是如何将XML转换成HTML ... -
web.xml详解
2010-10-22 09:18 674部署描述符实际上是一个XML文件,包含了很多描述servlet ... -
jsvalidation表单验证框架使用相关问题
2010-10-05 18:57 11351、如果验证框架没有起作用,就先把验证框架的js文件、x ... -
java中调用c(c++)写的dll 文件的实现及步骤
2010-09-08 10:08 1822JNI使用技巧点滴本文为 ... -
我的站点
2010-01-09 10:43 0www.51sj.com 我要设计 www.52sj.co ... -
Oracle创建删除用户、角色、表空间、导入导出数据库命令行方式总结
2009-12-18 21:31 2336说明: 在创建数据库时输入的密码,是修改系统默认的密码,以sy ... -
jdbc连接各种数据库
2009-12-18 21:08 817一、jsp连接Oracle8/8i/9i数据库(用thin模式 ... -
IOC
2009-11-02 11:36 1191介绍 IOC 作者:冰云 icecloud(AT) ...
相关推荐
首先,要使用JCOM,你需要从SourceForge等网站下载API,包含JCom的Java源码、C++代码以及必要的DLL文件。确保将DLL放置于Java的bin目录下,并正确设置JAVA_HOME环境变量。值得注意的是,JCOM的文档可能主要为日文,...
`Jcom.jar` 和 `jcom.dll` 是配套使用的,它们共同构成了一个解决方案,使得Java开发者能够利用Excel的特性,尤其是在打印方面。`Excel` 表明了该组件的应用场景,即处理电子表格。`java` 确认了这与Java编程语言...
jcom作为Java与Office的桥梁,使得开发者能够在不依赖Office本身的情况下,使用Java代码处理Office任务,极大地扩展了Java应用的能力。 压缩包中的jcom.jar和dll文件代表了这个库的核心组成部分。jcom.jar包含了...
值得注意的是,JCOM库的使用可能会受到Java版本和操作系统版本的影响,因此在实际应用中需要确保兼容性。同时,由于跨语言交互的复杂性,调试过程中可能需要对COM组件的日志和Java的异常堆栈信息进行分析。 总之,...
要使用JCom,首先需要了解以下几个关键概念: 1. **注册COM组件**:COM组件通常需要在Windows注册表中注册,以便其他应用程序能找到并使用它们。JCom通过读取注册表信息来查找和实例化COM对象。 2. **JCom库**:...
jcom-2.2.4是一款在IT行业中广泛使用的组件,它包含了两个核心文件——`jcom.dll`和`jcom.jar`,以及配套的API文档和Java源代码。本文将详细阐述这两个关键文件的功能和作用,并探讨其API文档和源码对于开发者的重要...
同时,由于`jcom.dll`是Windows特有的,所以只有在Windows环境下运行的Java程序才能使用JCom。对于非Windows系统,可能需要寻找其他兼容的库来实现类似的跨平台COM访问。 总之,JCom库为Java开发者提供了强大的能力...
标题"jcom.dll文件下载"指出我们关注的核心是"jcom.dll",这是一个动态链接库(Dynamic Link Library)文件,通常在Windows操作系统中使用。DLL文件包含可由多个程序同时使用的代码和数据,它有助于节省内存并促进...
本文将深入探讨JCOM的核心概念、工作原理以及如何使用它来实现跨平台的通讯。 首先,我们需要理解COM。COM是一种由微软公司提出的二进制标准,允许不同进程中的对象进行交互,常用于Windows环境下的软件开发。它的...
对于使用jcom的开发者来说,以下几个关键知识点是必须掌握的: 1. **JNI(Java Native Interface)**:jcom实现COM通信的关键技术之一就是JNI。JNI允许Java代码直接调用本地(非Java)代码,如C++,以实现与COM组件...
- **整合到项目**:将`jcom.jar`添加到Java项目的类路径,将`jcom.dll`放在系统能够找到的路径下(如Windows系统的`System32`目录),然后就可以在代码中使用`jcom`提供的功能了。 总之,`jcom.jar`和`jcom.dll`是...
在这个压缩包中,你可能会找到使用JCOM进行Excel打印的具体实现代码。 首先,我们需要理解Java中打印的基本概念。在Java中,打印主要是通过`java.awt.print`包中的类来实现的,如`PrinterJob`、`PageFormat`和`...
本教程将详细介绍如何使用`jcom`来实现Java写Excel的实例,并涵盖关键知识点。 首先,`jcom`库利用Java的JNI(Java Native Interface)技术,通过调用Windows平台上的`dll`文件与Excel进行通信。在Java项目中,你...
"Jcom转换office为pdf"这个主题涉及到的是如何使用Java库JCom来实现将Microsoft Office格式的文件(如Word、Excel、PowerPoint)转换成PDF格式。这种转换在多种场景下都是必要的,比如保证文档在不同平台和设备上的...
在Java应用程序中,如果我们需要对Word文档或Excel表格进行打印操作,而直接使用Java内置的打印API可能无法满足复杂的格式需求,这时候JCom提供了一个方便的解决方案。 JCom库的工作原理是通过Java的JNI(Java ...
Java的COM桥(JCom)是一种技术,它允许Java应用程序与使用组件对象模型(Component Object Model,简称COM)的组件进行交互。COM是Microsoft开发的一种软件接口技术,用于构建可重用的软件组件,通常在Windows环境...
基于java的开发源码-COM桥 JCom.zip 基于java的开发源码-COM桥 JCom.zip 基于java的开发源码-COM桥 JCom.zip 基于java的开发源码-COM桥 JCom.zip 基于java的开发源码-COM桥 JCom.zip 基于java的开发源码-COM桥 JCom....
在实际应用中,JCom的使用步骤大致如下: 1. 导入类型库:使用JCom提供的工具,如jcomgen,将COM组件的类型库转换为Java源代码。这将生成一组Java接口,这些接口定义了COM组件的方法和属性。 2. 创建COM组件实例:...
1. **导入JCom库**:在Java项目中引入JCom的JAR文件,以便使用其提供的API。 2. **加载COM组件**:通过JCom提供的API,如`ComRuntime`类,加载并实例化所需的COM组件。 3. **调用COM方法**:通过Java代理类,直接...