octscorpion

  BlogJava :: 首页 :: 联系 :: 聚合  :: 管理
  0 Posts :: 17 Stories :: 0 Comments :: 0 Trackbacks
  public static void excelPrint(String filePath) {
        ActiveXComponent xl 
= new ActiveXComponent("Excel.Application");
        
try {

            Dispatch.put(xl, 
"Visible"new Variant(false));
            Dispatch workbooks 
= xl.getProperty("Workbooks").toDispatch();
            Dispatch ex 
= Dispatch.call(workbooks, "Open", filePath).toDispatch();
            Dispatch.get(ex, 
"PrintOut");
        }
 catch (Exception e) {
            e.printStackTrace();
        }
 finally {
            xl.invoke(
"Quit"new Variant[] {});
            xl 
= null;

        }


    }
posted on 2012-12-12 17:38 一G刀客 阅读(292) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航: