安装 IBM Rational Team Concert Express-C
2011-01-07 12:16
316 查看
第一步:下载得到了jacob.jar
第二步: 将解压后的源代码包中jacob.dll存放到system32目录下。(注:目前比较稳定的版本分别为1.7、1.8、1.9,我用的是1.8版本)
package com.util;
import com.jacob.activeX.ActiveXComponent;
import com.jacob.com.Dispatch;
import com.jacob.com.Variant;
public class Jacob2Html {
public static final int WORD_HTML = 8;
public static final int PPT_HTML = 12;
public static final int EXCEL_HTML = 44;
/**
* PowerPoint转成HTML
*
* @param pptPath
* PowerPoint文件全路径
* @param htmlfile
* 转换后HTML存放路径
*/
public static void pptToHtml(String pptPath, String htmlPath) {
ActiveXComponent offCom = new ActiveXComponent("PowerPoint.Application");
try {
offCom.setProperty("Visible", new Variant(true));
Dispatch excels = offCom.getProperty("Presentations").toDispatch();
Dispatch excel = Dispatch.invoke(
excels,
"Open",
Dispatch.Method,
new Object[] { pptPath, new Variant(false),
new Variant(false) }, new int[1]).toDispatch();
Dispatch.invoke(excel, "SaveAs", Dispatch.Method, new Object[] {
htmlPath, new Variant(PPT_HTML) }, new int[1]);
Variant f = new Variant(false);
Dispatch.call(excel, "Close");
} catch (Exception e) {
e.printStackTrace();
} finally {
offCom.invoke("Quit", new Variant[] {});
}
}
/**
* WORD转成HTML
*
* @param wordPath
* WORD文件全路径
* @param htmlPath
* 生成的HTML存放路径
*/
public static void wordToHtml(String wordPath, String htmlPath) {
ActiveXComponent offCom = new ActiveXComponent("Word.Application");
try {
offCom.setProperty("Visible", new Variant(false));
Dispatch wordDis = offCom.getProperty("Documents").toDispatch();
Dispatch doc = Dispatch.invoke(
wordDis,
"Open",
Dispatch.Method,
new Object[] { wordPath, new Variant(false),
new Variant(true) }, new int[1]).toDispatch();
Dispatch.invoke(doc, "SaveAs", Dispatch.Method, new Object[] {
htmlPath, new Variant(WORD_HTML) }, new int[1]);
Variant f = new Variant(false);
Dispatch.call(doc, "Close", f);
} catch (Exception e) {
e.printStackTrace();
} finally {
offCom.invoke("Quit", new Variant[] {});
}
}
/**
* EXCEL转成HTML
*
* @param xlsfile
* EXCEL文件全路径
* @param htmlfile
* 转换后HTML存放路径
*/
public static void excelToHtml(String xlsfile, String htmlfile) {
ActiveXComponent app = new ActiveXComponent("Excel.Application"); // 启动word
try {
app.setProperty("Visible", new Variant(false));
Dispatch excels = app.getProperty("Workbooks").toDispatch();
Dispatch excel = Dispatch.invoke(
excels,
"Open",
Dispatch.Method,
new Object[] { xlsfile, new Variant(false),
new Variant(true) }, new int[1]).toDispatch();
Dispatch.invoke(excel, "SaveAs", Dispatch.Method, new Object[] {
htmlfile, new Variant(EXCEL_HTML) }, new int[1]);
Variant f = new Variant(false);
Dispatch.call(excel, "Close", f);
} catch (Exception e) {
e.printStackTrace();
} finally {
app.invoke("Quit", new Variant[] {});
}
}
}
第二步: 将解压后的源代码包中jacob.dll存放到system32目录下。(注:目前比较稳定的版本分别为1.7、1.8、1.9,我用的是1.8版本)
package com.util;
import com.jacob.activeX.ActiveXComponent;
import com.jacob.com.Dispatch;
import com.jacob.com.Variant;
public class Jacob2Html {
public static final int WORD_HTML = 8;
public static final int PPT_HTML = 12;
public static final int EXCEL_HTML = 44;
/**
* PowerPoint转成HTML
*
* @param pptPath
* PowerPoint文件全路径
* @param htmlfile
* 转换后HTML存放路径
*/
public static void pptToHtml(String pptPath, String htmlPath) {
ActiveXComponent offCom = new ActiveXComponent("PowerPoint.Application");
try {
offCom.setProperty("Visible", new Variant(true));
Dispatch excels = offCom.getProperty("Presentations").toDispatch();
Dispatch excel = Dispatch.invoke(
excels,
"Open",
Dispatch.Method,
new Object[] { pptPath, new Variant(false),
new Variant(false) }, new int[1]).toDispatch();
Dispatch.invoke(excel, "SaveAs", Dispatch.Method, new Object[] {
htmlPath, new Variant(PPT_HTML) }, new int[1]);
Variant f = new Variant(false);
Dispatch.call(excel, "Close");
} catch (Exception e) {
e.printStackTrace();
} finally {
offCom.invoke("Quit", new Variant[] {});
}
}
/**
* WORD转成HTML
*
* @param wordPath
* WORD文件全路径
* @param htmlPath
* 生成的HTML存放路径
*/
public static void wordToHtml(String wordPath, String htmlPath) {
ActiveXComponent offCom = new ActiveXComponent("Word.Application");
try {
offCom.setProperty("Visible", new Variant(false));
Dispatch wordDis = offCom.getProperty("Documents").toDispatch();
Dispatch doc = Dispatch.invoke(
wordDis,
"Open",
Dispatch.Method,
new Object[] { wordPath, new Variant(false),
new Variant(true) }, new int[1]).toDispatch();
Dispatch.invoke(doc, "SaveAs", Dispatch.Method, new Object[] {
htmlPath, new Variant(WORD_HTML) }, new int[1]);
Variant f = new Variant(false);
Dispatch.call(doc, "Close", f);
} catch (Exception e) {
e.printStackTrace();
} finally {
offCom.invoke("Quit", new Variant[] {});
}
}
/**
* EXCEL转成HTML
*
* @param xlsfile
* EXCEL文件全路径
* @param htmlfile
* 转换后HTML存放路径
*/
public static void excelToHtml(String xlsfile, String htmlfile) {
ActiveXComponent app = new ActiveXComponent("Excel.Application"); // 启动word
try {
app.setProperty("Visible", new Variant(false));
Dispatch excels = app.getProperty("Workbooks").toDispatch();
Dispatch excel = Dispatch.invoke(
excels,
"Open",
Dispatch.Method,
new Object[] { xlsfile, new Variant(false),
new Variant(true) }, new int[1]).toDispatch();
Dispatch.invoke(excel, "SaveAs", Dispatch.Method, new Object[] {
htmlfile, new Variant(EXCEL_HTML) }, new int[1]);
Variant f = new Variant(false);
Dispatch.call(excel, "Close", f);
} catch (Exception e) {
e.printStackTrace();
} finally {
app.invoke("Quit", new Variant[] {});
}
}
}
相关文章推荐
- Jazz 最新更新:安装 IBM Rational Team Concert Express-C
- IBM Rational Team Concert的安装和试用
- IBM RTC 4.0.7–Rational Team Concert 安装记录
- 教程:体验 Jazz,体验 Rational Team Concert Express
- IBM Rational Team Concert 技术体验
- 通过 Jazz 和 IBM Rational Team Concert 进行测试管理
- IBM Rational Team Concert
- 通过 Jazz 和 IBM Rational Team Concert 进行测试管理
- IBM Rational Team Concert 学习路线图
- 在 IBM Rational Team Concert 平台上实现 Scrum 敏捷项目管理
- Rational Team Concert 3.0安装
- 如何使用 IBM Rational Method Composer 为 IBM Rational Team Concert 文档化您的团队过程
- IBM Rational Team Concert 1.0 正式发布
- 聚焦IBM Rational Team Concert 与 Jazz软件解决方案
- IBM Rational Team Concert浅谈
- IBM Rational Team Concert
- IBM Rational Team Concert 3.0 11月23号发布
- Rational Team Concert 3.0发布了及新特点
- 从传统的 Subversion(SVN)转向基于 Rational Team Concert 的协作
- IBM.Rational.Rose.Enterprise.7.0下载及 安装过程