 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;

}

}
|