zoukankan      html  css  js  c++  java
  • (原)用WebBrowser浏览Office Web Apps Server,除去“下载”按钮

    对,没错,如果你按关键字找到这篇随笔了,相信一定知道背景,以及我所说的是什么。


    上一段子代码。

    private void timerHideButton_Tick(object sender, EventArgs e)
            {
                try
                {
                    HtmlDocument htmlDoc = webBrowser.Document;
                    if (webBrowser.Document != null) 
                        htmlDoc = webBrowser.Document.Window.Frames["wacframe"].Document;
                    if (htmlDoc == null)
                        return;
    
                    var toolBar = htmlDoc.GetElementById("PptUpperToolbar.LeftButtonDock");    //PPT、PPTX
                    if (toolBar == null)      
                        toolBar = htmlDoc.GetElementById("stripLeft");                 //DOC、DOCX、PDF
                    if (toolBar == null)
                        toolBar = htmlDoc.GetElementById("m_excelWebRenderer_ewaCtl_stripLeft"); //XLS、XLSX
    
                    if (toolBar != null)
                    {
                        toolBar.InnerHtml = "";
                        timerHideButton.Enabled = false;
                    }
                }
                catch (Exception ex)
                {
                   Console.WriteLine(ex.Message);
                }
            }
    

      张三问了:还用个Timer,不科学,你应该把代码放到
                             webBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e);

           回答:原先我也是这么想的,但是、可是因为 iframe 的原因,Completed事件可能会被激活多次,并且直到最后一次也不能准确得到预期结果。

  • 相关阅读:
    作业4
    PSP记录个人项目耗时
    代码复审
    是否需要有代码规范?
    作业二(1)
    作业二(2)
    作业一
    软件工程学期总结
    作业4
    作业3(PSP表格)
  • 原文地址:https://www.cnblogs.com/spymaster/p/8204757.html
Copyright © 2011-2022 走看看