public static void excelToHtml(String xlsfile, String htmlfile)
{ ActiveXComponent app = new ActiveXComponent ("Excel.Application"); // 啟動(dòng)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[] {}); } } } 這里面要用到Office主鍵,其實(shí)和word轉(zhuǎn)換成html的也差不多,我在word已經(jīng)附屬過這里就不強(qiáng)調(diào)了。。
|
|