Wednesday 25 May 2016

SharePoint Custom Button to Export list data to Excel.

Process: 

<input type="button" style="width:180px; height: 75px; 30px;background:gray; color:white;font-size:larger; font-weight:bold;"onclick="window.location.href='SITEURL/_vti_bin/owssvr.dll?CS=109&Using=_layouts/query.iqy&List={YOUR LIST ID}&View={YOUR VIEW ID}&CacheControl=1';" value ="YOUR BUTTON TEXT"/>


The code above is essentially everything that you will need for a simple Excel Export button.  In order to get the code to work, you will need to update the SITEURL, YOUR LIST ID, YOUR VIEW ID, & YOUR BUTTON TEXT.

How to get these Data:

  • Go to the list which you want to export to Excel.
  • In the ribbon, click on export to Excel.
  • A file will get saved to your local system. 
  • Open the file in notepad.
  • You will get the the List ID and View ID.
  • Go to the particular site and in the URL copy till that site/subsite. This is your Site URL.
Now add all the data to above link and use it in your code.

Example:


 <input type="button" style="width:180px; height: 75px; 30px;background:gray; color:white;font-size:larger; font-weight:bold;"
onclick="window.location.href='http://HostServer00081:3000//_vti_bin/owssvr.dll?CS=109&Using=_layouts/query.iqy&List={FBDA49D4-3206-4408-A5BC-ACC9422D4ADB}&View={F5371271-9A16-46CA-8D57-5B2198587AD9}&CacheControl=1';"
value ="Export to Excel"/>


---

Thanks.

No comments:

Post a Comment