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事件可能会被激活多次,并且直到最后一次也不能准确得到预期结果。

  • 相关阅读:
    递归
    递归
    递归
    San Francisco Crime Classification非数值性多分类问题
    kaggle入门题Titanic
    二叉树的前序,中序,后序,层序遍历的递归和非递归实现
    排序算法总结
    [LeetCode]148. Sort List链表归并排序
    [LeetCode]141. Linked List Cycle判断循环链表
    [leetcode]61. Rotate List反转链表k个节点
  • 原文地址:https://www.cnblogs.com/spymaster/p/8204757.html
Copyright © 2011-2022 走看看