本文整理汇总了Java中com.jacob.activeX.ActiveXComponent.invoke方法的典型用法代码示例。如果您正苦于以下问题:Java ActiveXComponent.invoke方法的具体用法?Java ActiveXComponent.invoke怎么用?Java ActiveXComponent.invoke使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jacob.activeX.ActiveXComponent
的用法示例。
在下文中一共展示了ActiveXComponent.invoke方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: word2PDF
import com.jacob.activeX.ActiveXComponent; //导入方法依赖的package包/类
private void word2PDF(String inputFile, String pdfFile) {
// 打开word应用程序
ActiveXComponent app = new ActiveXComponent("Word.Application");
// 设置word不可见
app.setProperty("Visible", false);
// 获得word中所有打开的文档,返回Documents对象
Dispatch docs = app.getProperty("Documents").toDispatch();
// 调用Documents对象中Open方法打开文档,并返回打开的文档对象Document
Dispatch doc = Dispatch.call(docs, "Open", inputFile, false, true).toDispatch();
// 调用Document对象的ExportAsFixedFormat方法,将文档保存为pdf格式
Dispatch.call(doc, "ExportAsFixedFormat", pdfFile, WORD_VALUE);// word保存为pdf格式宏,值为17
// 关闭文档
Dispatch.call(doc, "Close", false);
// 关闭word应用程序
app.invoke("Quit", 0);
}
示例2: excel2PDF
import com.jacob.activeX.ActiveXComponent; //导入方法依赖的package包/类
public boolean excel2PDF(String inputFile, String pdfFile) {
try {
ActiveXComponent app = new ActiveXComponent("Excel.Application");
app.setProperty("Visible", false);
Dispatch excels = app.getProperty("Workbooks").toDispatch();
Dispatch excel = Dispatch.call(excels, "Open", inputFile, false,
true).toDispatch();
Dispatch.call(excel, "ExportAsFixedFormat", xlTypePDF, pdfFile);
Dispatch.call(excel, "Close", false);
app.invoke("Quit");
return true;
} catch (Exception e) {
return false;
}
}
示例3: ppt2PDF
import com.jacob.activeX.ActiveXComponent; //导入方法依赖的package包/类
public boolean ppt2PDF(String inputFile, String pdfFile) {
try {
ActiveXComponent app = new ActiveXComponent(
"PowerPoint.Application");
// app.setProperty("Visible", msofalse);
Dispatch ppts = app.getProperty("Presentations").toDispatch();
Dispatch ppt = Dispatch.call(ppts, "Open", inputFile, true,// ReadOnly
true,// Untitled指定文件是否有标题
false// WithWindow指定文件是否可见
).toDispatch();
Dispatch.call(ppt, "SaveAs", pdfFile, ppSaveAsPDF);
Dispatch.call(ppt, "Close");
app.invoke("Quit");
return true;
} catch (Exception e) {
return false;
}
}
示例4: test01
import com.jacob.activeX.ActiveXComponent; //导入方法依赖的package包/类
public void test01(){
System.out.println("test01");
System.out.println("========");
ActiveXComponent drv = new ActiveXComponent("Addin.DRvFR");
System.out.println("res code = "+drv.getProperty("ResultCode"));
System.out.println("res code desc = "+drv.getProperty("ResultCodeDescription"));
System.out.println("show properties");
drv.invoke("ShowProperties");
System.out.println("res code = "+drv.getProperty("ResultCode"));
System.out.println("res code desc = "+drv.getProperty("ResultCodeDescription"));
}
示例5: excel2PDF
import com.jacob.activeX.ActiveXComponent; //导入方法依赖的package包/类
private void excel2PDF(String inputFile, String pdfFile) {
ActiveXComponent app = new ActiveXComponent("Excel.Application");
app.setProperty("Visible", false);
Dispatch excels = app.getProperty("Workbooks").toDispatch();
Dispatch excel = Dispatch.call(excels, "Open", inputFile, false, true).toDispatch();
Dispatch.call(excel, "ExportAsFixedFormat", EXCEL_VALUE, pdfFile);
Dispatch.call(excel, "Close", false);
app.invoke("Quit");
}
示例6: ppt2PDF
import com.jacob.activeX.ActiveXComponent; //导入方法依赖的package包/类
private void ppt2PDF(String inputFile, String pdfFile) {
ActiveXComponent app = new ActiveXComponent("PowerPoint.Application");
// app.setProperty("Visible", msofalse);
Dispatch ppts = app.getProperty("Presentations").toDispatch();
Dispatch ppt = Dispatch.call(ppts, "Open", inputFile, true, // ReadOnly
true, // Untitled指定文件是否有标题
false// WithWindow指定文件是否可见
).toDispatch();
Dispatch.call(ppt, "SaveAs", pdfFile, PPT_VALUE);
Dispatch.call(ppt, "Close");
app.invoke("Quit");
}
示例7: word2PDF
import com.jacob.activeX.ActiveXComponent; //导入方法依赖的package包/类
public boolean word2PDF(String inputFile, String pdfFile) {
try {
// 打开word应用程序
ActiveXComponent app = new ActiveXComponent("Word.Application");
// 设置word不可见
app.setProperty("Visible", false);
// 获得word中所有打开的文档,返回Documents对象
Dispatch docs = app.getProperty("Documents").toDispatch();
// 调用Documents对象中Open方法打开文档,并返回打开的文档对象Document
Dispatch doc = Dispatch.call(docs, "Open", inputFile, false, true)
.toDispatch();
// 调用Document对象的SaveAs方法,将文档保存为pdf格式
/*
* Dispatch.call(doc, "SaveAs", pdfFile, wdFormatPDF
* //word保存为pdf格式宏,值为17 );
*/
Dispatch.call(doc, "ExportAsFixedFormat", pdfFile, wdFormatPDF // word保存为pdf格式宏,值为17
);
// 关闭文档
Dispatch.call(doc, "Close", false);
// 关闭word应用程序
app.invoke("Quit", 0);
return true;
} catch (Exception e) {
return false;
}
}