word 2 html

public class Word2Html {

	public static void change(String docfile, String htmlfile) {
		ActiveXComponent app = new ActiveXComponent("Word.Application"); 
		try {
			app.setProperty("Visible", new Variant(false));
			Dispatch docs = app.getProperty("Documents").toDispatch(); 
			Dispatch doc = Dispatch.invoke(docs,"Open",Dispatch.Method,new Object[] { docfile, new Variant(false),new Variant(true) }, new int[1]).toDispatch(); 
			Dispatch.invoke(doc, "SaveAs", Dispatch.Method, new Object[] {htmlfile, new Variant(8) }, new int[1]);
			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.change("c:\\tmp\\jeans.doc", "c:\\tmp\\jeans"); 
		} catch (Throwable t) {
			t.printStackTrace();
		}
	}

}

 

你可能感兴趣的:(html,C++,c,F#,C#)