none
Move Export to Excel from Ribbon to Custom Navigation Bar RRS feed

  • Question

  • Greetings All,

    i've already the below code and its working very well. However, i need to have another button similar to search & refresh button  to be Export to Excel. i know that its available  for users in Ribbon menu. & i removed Tabular view for some security reason to me. So, My requirement is to have the button with below snippet as possible. 

    <style type="text/css">
    .cal-nav a{ font-size:16px; padding:10px 0px; width:250px; display:inline-block; background-color:rgb(103,106,110); color:#fff; margin-right:5px; text-align:center; -moz-border-radius: 9px 9px 0px 0px; -webkit-border-radius: 9px 9px 0px 0px; border-radius: 9px 9px 0px 0px; }
    .cal-nav a.selected{ background-color:#676a6e; }
    .cal-nav a:Hover{ background-color:#84BD00; text-decoration:none; }
    H1.ms-core-pageTitle { display:none;}
    .tab-desc { background-color:#676a6e; color:#fff !important; padding:5px;}
    .tab-desc H2 { color:#fff !important;}
    </style>
    
     
       
             <script type="text/javascript">
     function RedirectUrl() {
     var tb = document.getElementById("tbSearch").value;
     var cs = document.getElementById("sfield").value;
     var url = "";
    
     if (tb != "") {
      if (cs == "Column5" || cs == "Column6"){
      url = "FilterField1=" + cs + "&FilterValue1=" + tb;
      window.location.href = "HR.aspx" + url;
      }
      else {  
      url = "FilterName=" + cs + "&FilterMultiValue=*" + tb + "*";
      window.location.href = "HR.aspx" + url;
      }
      }
      else {
      return false;
      }
     } 
     function ClearUrl() {
     window.location.href = "HR.aspx";
     }
    </script> 
             <p>&#160;Search Field: 
                <select id="sfield" style="width: 157px;">
                   <option value="LoginID">ID</option><option value="Title">Request No</option></select> Search text: 
                <input id="tbSearch" type="text"/>
                <input id="btnSearch" onclick="return RedirectUrl();" type="button" size="11" value="Search" style="width: 66px; height: 33px;"/>
                <input id="btnClear" onclick="return ClearUrl();" type="button" value="Refresh" style="width: 66px; height: 31px;"/>  
                <br/><style>

    Thanks and appreciated your help. 

    Monday, June 29, 2020 8:58 PM

Answers

  • Hi Majedix,

    I understand you want to make a custom button that could export list to excel just like the built-in ribbon.

    In fact, when you click 'export to excel', the corresponding request is: 

    Request URL: http://sp/_vti_bin/owssvr.dll?CS=65001&Using=_layouts/15/query.iqy&List=%7BA3D9FD68%2DAA12%2D474A%2D8FB7%2DACD6E6D9C4C6%7D&View=%7BB31DF607%2D0B2E%2D4587%2D99E9%2D9D11BB4B51AE%7D&RootFolder=%2FLists%2FProject&CacheControl=1

    Hence we may copy the action link then generated the button. 

    You can take a reference of below blog:

    Best Regards,

    Baker Kong


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click  here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    • Marked as answer by Majedix Tuesday, June 30, 2020 12:35 PM
    Tuesday, June 30, 2020 2:53 AM

All replies

  • Hi Majedix,

    I understand you want to make a custom button that could export list to excel just like the built-in ribbon.

    In fact, when you click 'export to excel', the corresponding request is: 

    Request URL: http://sp/_vti_bin/owssvr.dll?CS=65001&Using=_layouts/15/query.iqy&List=%7BA3D9FD68%2DAA12%2D474A%2D8FB7%2DACD6E6D9C4C6%7D&View=%7BB31DF607%2D0B2E%2D4587%2D99E9%2D9D11BB4B51AE%7D&RootFolder=%2FLists%2FProject&CacheControl=1

    Hence we may copy the action link then generated the button. 

    You can take a reference of below blog:

    Best Regards,

    Baker Kong


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click  here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    • Marked as answer by Majedix Tuesday, June 30, 2020 12:35 PM
    Tuesday, June 30, 2020 2:53 AM
  • worked as described. appreciated. 
    Tuesday, June 30, 2020 12:36 PM