我使用jacob将excel另存为pdf格式,怎么才能转换整个工作簿另存为pdf,只能存当前活动sheet,代码如下Dispatch sheet = Dispatch.invoke(sheets, "Item", Dispatch.Get,
new Object[] { new Integer(1) }, new int[1]).toDispatch();
// String sheetname = Dispatch.get(sheet, "name").toString();
Dispatch.call(sheet, "Activate");//指定活动sheet
Dispatch.call(sheet, "Select");
int excelToPdf = 57;
Dispatch.invoke(excel, "SaveAs", Dispatch.Method, new Object[] {
outFile, new Variant(excelToPdf), new Variant(true),
new Variant(excelToPdf), new Variant(excelToPdf),
new Variant(true), new Variant(true),
new Variant(excelToPdf), new Variant(true),
new Variant(true), new Variant(true) }, new int[1]);
Dispatch.call(excel, "Close", new Variant(false));
100分跪求,来大神解决
解决方案 »
- 传说中的Exception in threads "main" java.lang.NoClassDefFoundError: 试了n种方法了,求救.....
- 在jboss下部署2个war包,会产生静态变量相同的结果,怎么办?
- Struts 2.0的输入效验的一个小问题
- 晕了,给看看怎么又错了。
- java的两道小计算
- 手机键盘那样的程序
- 运行struts程序时遇到的异常
- 请问谁有weblogic与active directory的经验
- The WebLogic Server did not start up properly.
- (彻底解决再送100,绝不食言!)《精通EJB第二版》的实体BEAN例子。
- spring注入失败
- struts和hibernate整合开发,怎么从数据库取出所有对象?
Dispatch.call(sheet, "Activate");//指定活动sheet
这句你是指定了活动的sheet,所以只保存了当前活动的sheet。试试下面这样呢
ActiveXComponent app = new ActiveXComponent("Excel.Application");
Dispatch excels = app.getProperty("Workbooks").toDispatch();
Dispatch.invoke(excel, "SaveAs", Dispatch.Method, new Object[]
Dispatch.call(sheet, "Activate");//指定活动sheet
这句你是指定了活动的sheet,所以只保存了当前活动的sheet。试试下面这样呢
ActiveXComponent app = new ActiveXComponent("Excel.Application");
Dispatch excels = app.getProperty("Workbooks").toDispatch();
Dispatch.invoke(excel, "SaveAs", Dispatch.Method, new Object[]
试了下,不指定就是默认第一个sheet...
Dispatch.call(sheet, "Activate");//指定活动sheet
这句你是指定了活动的sheet,所以只保存了当前活动的sheet。试试下面这样呢
ActiveXComponent app = new ActiveXComponent("Excel.Application");
Dispatch excels = app.getProperty("Workbooks").toDispatch();
Dispatch.invoke(excel, "SaveAs", Dispatch.Method, new Object[]
试了下,不指定就是默认第一个sheet...???????????你的代码是不是贴的不全。。