Create a button to Export SharePoint List View to Excel

Export SharePoint List


For a recent client I was asked to set up a quick and easy link for them to Export the customized SharePoint list that I built for them with SPD workflow and InfoPath forms attached. It’s fairy easy to do, very repeatable and saves the client clicks!

This is the end result (very easy to edit):

Build the Button

Copy-Paste the following code to your favorite text editor:

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

To customize your button’s appearance, you can edit any of the following stye parameters:
button width – width: 180px;
button height – height: 35px;
button color – background: gray;
text color – color: white;
text size – font-size: larger;
font-weight: bold;

Finally, edit the button’s text, or Call To Action, by editing the code at the end of above: value = “BUTTON CTA” (don’t lose the quotations).

Next, let’s Connect your button to Your SharePoint List View for exporting.

Connect to SharePoint

As with all things SharePoint, there’s a multitude of methods to accomplish what you want to accomplish, here’s what I found to work easiest for connecting your customized button to your customized SharePoint List.

First, Click on your customized SharePoint list ‘List Settings’.

Scroll to the bottom of your List Settings page and Click on the correct list view you are looking to export.

Copy the FULL URL for this list view.

To extract the SharePoint list information for your custom button, Go to the following website:

Simply Copy-Paste your above captured SharePoint list view URL into the box on this website’s page and click Decode

This will turn the verrrry, long gibberish you copied from your SharePoint list view to a slightly shorter Guid-ready version of gibberish.
Now we’re ready to make the connections!

Copy-Paste the SharePoint site URL and Guid information from the decoding website above to the respective place within the button configuration text file you created at the beginning of this whole thing.

SharePoint List GUID Decoded

Copy-Paste the below listed areas from the Decoded website:

{SITE URL} – https://yoursharepoint site information (lose the brackets)
{LIST GUID} – List = {XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXX} (don’t lose the brackets)
{VIEW GUID} – View = {XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXX} (don’t lose the brackets)

Finish It Up!

Now that you have copy-pasted all the appropriate “stuff” into your text editor, Save the file as a text file, e.g., ListExportButton.txt.

Save the text file to your SharePoint site, I utilize the Site Assets document folder for this purpose.

To insert the custom button, Open and Edit your page where you need the button.
Insert a Content Editor webpart and link it to the file you saved in your SharePoint document library (Site Assets).

Content Editor Webpart

Click Apply and then OK and Save your page.

Now that you have created your custom-Export-To-Excel SharePoint List button, once your Click it, two popups will appear

Click Open, Excel will open up on your desktop and another popup will appear

Click Enable. Excel will continue to open with your complete SharePoint List View downloaded!