Export List to Excel Button

Export List to Excel Button

Summary: Any user with read access can export a list or library to excel from the list/library ribbon. Yet some users may want to have a button visible on the screen to export a view of items. Below is a small script you can edit that will add an export button to your page. In the scenario where I implemented this solution, the view was filtered to show all items that the people picker field is equal to [Me]. The export button only exported the items relevant to Me.

Instructions:

  1. Add a content editor webpart to the page, on the format text ribbon select Edit Source
  2. Copy the below code and replace the bold text with the relvant information from your site.
    <input onclick=”window.location.href=&#39;[YOUR SITE URL]/_vti_bin/owssvr.dll?CS=109&amp;Using=_layouts/query.iqy&amp;List={YOUR LIST ID}&amp;View={YOU VIEW ID}&amp;CacheControl=1&#39;;” type=”button” value=”Export Members”/>
  3. Paste the code into the Source Editor

How to get the List ID:

  1. Navigate to the list/library settings
  2. In the list settings URL you will see: List=%7BEEA391B8%2DBD9C%2D4A20%2DB765%2DA6B945E6B9A4%7D
    That is your ID but it needs some clean up.
  3. Remove %7B from the beginning of the URL. Remove %7D from the end of the URL. Replace all %2d to –
  4. Final List ID: EEA391B8-BD9C-4A20-B765-A6B945E6B9A4

How to get the View ID:

  1. Navigate to list/library settings
  2. At the bottom of the page you will see a view section, select the desired view
  3. In the URL you will see: View=%7B93B0D020%2D48DB%2D4881%2D984F%2D581DEFDF6D6C%7D&Source=
  4. Your ID is from the = until the &Source and again the ID needs some clean up.
  5. Remove %7B from the beginning of the URL. Remove %7D from the end of the URL. Replace all %2d to –
  6. Final View ID: 93B0D020-48DB-4881-984F-581DEFDF6D6C