jeans 发表于 2013-1-27 04:45:59

excel 2 html

public class Excel2Html {public static void change2Html(String docfile, String htmlfile) {ActiveXComponent app = new ActiveXComponent("Excel.Application"); try {app.setProperty("Visible", new Variant(false));Dispatch docs = app.getProperty("Workbooks").toDispatch(); Dispatch doc = Dispatch.invoke(docs,"Open",Dispatch.Method,new Object[] { docfile, new Variant(false),new Variant(true) }, new int).toDispatch(); Dispatch.invoke(doc, "SaveAs", Dispatch.Method, new Object[] {htmlfile, new Variant(44) }, new int);Variant f = new Variant(false); Dispatch.call(doc, "Close", f); } catch (Exception e) {e.printStackTrace(); } finally {app.invoke("Quit", new Variant[]{}); }}public static void main(String[] args) {try {Excel2Html.change2Html("c:\\tmp\\jeans.xls", "c:\\tmp\\jeans"); } catch (Throwable t) {t.printStackTrace();}}} 
页: [1]
查看完整版本: excel 2 html