locked
Is it possible to set export to excel and print button in page RRS feed

  • Question

  • like the picture ..

    I want to insert 2 botton

    export to excel like in the ribbon interface and print lists that in the page

    Thanks.

    Thursday, July 25, 2013 3:18 AM

Answers

  • Hi,

    Print button:

    Please be aware that the button will be included.

    <input onclick="window.print();return false;" type="button" value=" Print "/>

    Export button:

    The reason why you cannot export to excel even when you add the list & view GUID is because the code Mahesh.Nalam provides will return URL like:

    {site url}/list/_vti_bin/owssvr.dll?CS=109&Using=_layouts/query.iqy&List=......

    While the real one should be:

    {site url}/_vti_bin/owssvr.dll?CS=109&Using=_layouts/query.iqy&List=......

    Therefore, you should check the JS which can help to retrieve the site URL.

    http://sharepoint.stackexchange.com/questions/24817/get-site-collection-full-url-using-javascript


    <p style="margin:0cm 0cm 0pt"><span lang="EN-US" style="color:#0070c0; font-family:&quot;Segoe UI&quot;,&quot;sans-serif&quot;; font-size:10pt">Miles LI<br/> TechNet Community Support</span></p> <p style="margin:0cm 0cm 0pt"><a href="http://blogs.technet.com/b/onescript" rel="nofollow"><img src="https://xnoegg.bay.livefilestore.com/y1plmwd9pFqoTZWcmr6-bsBuS7hTcNbr8YdT4WL3RRAuhDPVyUUOVchQt3EexNEBj4xYyornsD1kyLmtVqqsDfKv3PEEg9ejQzT/signature.jpg?psid=1" alt="" width="430" height="30.2"></a></p>

    • Marked as answer by Qiao Wei Monday, August 5, 2013 3:28 PM
    Thursday, August 1, 2013 9:00 AM

All replies

  • Hi Tippaa,

    Regarding "Export to Excel" functionality on custom button click, You can insert following code snippet by placing the GUID of list & view:

    <a href="#" onclick="javascript:window.location='../_vti_bin/owssvr.dll?CS=109&Using=_layouts/query.iqy&List=GUID&View=GUID&CacheControl=1'"><img src="/_layouts/images/icxlsx.gif" border="0"/>&nbsp;&nbsp; Export to Excel</a>

    For Printing you can write some JQuery like this:

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js" type="text/javascript"></script>
    
    <script>
    
    $(document).ready(function() {
    
      $(‘.printMe’).click(function() {
      window.print();
      return false;
      });
    
    });</script>

    Please go through following article for further reference:

    http://asim-reusablecode.blogspot.sg/2012/10/how-to-call-default-sharepoint-2010.html

    http://chayadigital.wordpress.com/2013/02/19/add-a-quick-print-button-to-a-form-display-in-sharepoint-2010-using-simple-jquery-snippet/

    Following Link for printing entire List:

    http://spprintlistbutton.codeplex.com/

    Following URL for Export to Excel custom solution by using SPGridView:

    http://www.fivenumber.com/export-spgridview-to-excel-spreadsheet-in-sharepoint-2007/


    Please don't forget to 'mark answer/propose answer' or 'vote as helpful' as appropriate.


    • Edited by Mahesh.Nalam Thursday, July 25, 2013 4:51 AM more info
    • Proposed as answer by HeToC Thursday, July 25, 2013 8:15 AM
    • Unproposed as answer by Hemendra Agrawal Wednesday, July 31, 2013 5:35 AM
    Thursday, July 25, 2013 4:49 AM
  • Thanks Mahesh.Nalam,

    I have done that before I ask question. But It's not work. both excel and print buttons that you suggest. 

    In export to excel button I also change list & view ID. But it's not happen ... so what should I can do

    please help

    Thursday, July 25, 2013 8:34 AM
  • Hi,

    Print button:

    Please be aware that the button will be included.

    <input onclick="window.print();return false;" type="button" value=" Print "/>

    Export button:

    The reason why you cannot export to excel even when you add the list & view GUID is because the code Mahesh.Nalam provides will return URL like:

    {site url}/list/_vti_bin/owssvr.dll?CS=109&Using=_layouts/query.iqy&List=......

    While the real one should be:

    {site url}/_vti_bin/owssvr.dll?CS=109&Using=_layouts/query.iqy&List=......

    Therefore, you should check the JS which can help to retrieve the site URL.

    http://sharepoint.stackexchange.com/questions/24817/get-site-collection-full-url-using-javascript


    <p style="margin:0cm 0cm 0pt"><span lang="EN-US" style="color:#0070c0; font-family:&quot;Segoe UI&quot;,&quot;sans-serif&quot;; font-size:10pt">Miles LI<br/> TechNet Community Support</span></p> <p style="margin:0cm 0cm 0pt"><a href="http://blogs.technet.com/b/onescript" rel="nofollow"><img src="https://xnoegg.bay.livefilestore.com/y1plmwd9pFqoTZWcmr6-bsBuS7hTcNbr8YdT4WL3RRAuhDPVyUUOVchQt3EexNEBj4xYyornsD1kyLmtVqqsDfKv3PEEg9ejQzT/signature.jpg?psid=1" alt="" width="430" height="30.2"></a></p>

    • Marked as answer by Qiao Wei Monday, August 5, 2013 3:28 PM
    Thursday, August 1, 2013 9:00 AM
  • Almost.......In SharePoint 2013, 

    I used the F12 developer tools -> Network to trap the URL after I clicked on the ribbon to Export to Excel button.

    http://shptr2dev01:90/_vti_bin/owssvr.dll?CS=65001&Using=_layouts/15/query.iqy&List=%7BCAA37184%2DA83F%2D44D6%2D895D%2D38EFB6891D3F%7D&View=%7BA1DB7DB2%2D526E%2D4C41%2D85EE%2D9441FDB8909A%7D&RootFolder=%2FIST&CacheControl=1

    It is just that simple. Test a hardcoded list ID. Once can retrieve the list ID in the URL after navigating to Library settings, Audience.

    Friday, January 12, 2018 12:37 AM