jacob-1.18-M2
JACOB一个Java-COM中间件.通过这个组件你可以在Java应用程序中调用COM组件和Win32程序库。 示例代码: /** * 转换xls到pdf * @param excelFile * @param pdfFile */ public static void converExcelToPdf(String excelFile,String pdfFile){ ActiveXComponent app = new ActiveXComponent("Excel.Application"); try { app.setProperty("Visible", false); Dispatch workbooks = app.getProperty("Workbooks").toDispatch(); //打开文件 Dispatch workbook = Dispatch.invoke(workbooks, "Open", Dispatch.Method, new Object[] { excelFile, new Variant(false), new Variant(false) }, new int[3]).toDispatch(); //另存为文件 Dispatch.invoke(workbook, "SaveAs", Dispatch.Method, new Object[] {pdfFile, new Variant(57), new Variant(false), new Variant(57), new Variant(57), new Variant(false), new Variant(true), new Variant(57), new Variant(true), new Variant(true), new Variant(true) }, new int[1]); //关闭 Dispatch.call(workbook, "Close", new Variant(false)); } catch (Exception e) { throw new SmileRunException("excel 转 pdf出错 excel:"+excelFile+",pdf:"+pdfFile,e); } finally { if (app != null) { app.invoke("Quit", new Variant[] {}); } } }
- 1
- 粉丝: 0
- 资源: 7
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助