分享

Excel转换成html

 实力决定地位 2010-12-29
  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已经附属过这里就不强调了。。

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约