本文整理汇总了Java中com.jacob.activeX.ActiveXComponent.setProperty方法的典型用法代码示例。如果您正苦于以下问题:Java ActiveXComponent.setProperty方法的具体用法?Java ActiveXComponent.setProperty怎么用?Java ActiveXComponent.setProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jacob.activeX.ActiveXComponent
的用法示例。
在下文中一共展示了ActiveXComponent.setProperty方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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");
}
示例4: 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;
}
}
示例5: output
import com.jacob.activeX.ActiveXComponent; //导入方法依赖的package包/类
public void output(File cWordFile, ControlText resultRootText, LongStyleManagerWord lsManager,
IntermediateTextTreeWalker cTreeWalker) {
boolean tVisible = Tx2xOptions.getInstance().getBoolean("Visible");
ActiveXComponent oWord = new ActiveXComponent("Word.Application");
oWord.setProperty("Visible", new Variant(tVisible));
Dispatch oDocuments = oWord.getProperty("Documents").toDispatch();
try {
Dispatch.call(oDocuments, "Add", cWordFile.getParent() + "\\" + m_sTemplateDoc).toDispatch();
Dispatch oSelection = oWord.getProperty("Selection").toDispatch();
// 書き込み
outputResult(oSelection, resultRootText, lsManager, cTreeWalker);
// 保存
Dispatch oDocument = Dispatch.call(oSelection, "Document").toDispatch();
Dispatch.call(oDocument, "SaveAs2", cWordFile.getAbsolutePath(), 12 /* wdFormatXMLDocument */);
oWord.setProperty("Visible", new Variant(true));
} catch (IOException e1) {
e1.printStackTrace();
} catch (ComFailException e) {
System.out.println("---------- error ----------\n" + e.getLocalizedMessage());
if (e.getLocalizedMessage().indexOf("Description: ファイルが見つかりません。") != -1) {
System.out.println(cWordFile.getParent() + "\\" + m_sTemplateDoc);
}
System.out.println("---------------------------");
}
}