• 注册
当前位置:1313e > html >正文

excel转换成html预览,Excel转换成html

public static void excelToHtml(String xlsfile, String htmlfile)

{

ActiveXComponent app = new ActiveXComponent

("Excel.Application"); // 启动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主键,其实和word转换成html的也差不多,我在word已经附属过这里就不强调了。。

本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 162202241@qq.com 举报,一经查实,本站将立刻删除。

最新评论

欢迎您发表评论:

请登录之后再进行评论

登录