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:
- Add a content editor webpart to the page, on the format text ribbon select Edit Source
- Copy the below code and replace the bold text with the relvant information from your site.
<input onclick=”window.location.href='[YOUR SITE URL]/_vti_bin/owssvr.dll?CS=109&Using=_layouts/query.iqy&List={YOUR LIST ID}&View={YOU VIEW ID}&CacheControl=1';” type=”button” value=”Export Members”/> - Paste the code into the Source Editor
How to get the List ID:
- Navigate to the list/library settings
- 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. - Remove %7B from the beginning of the URL. Remove %7D from the end of the URL. Replace all %2d to –
- Final List ID: EEA391B8-BD9C-4A20-B765-A6B945E6B9A4
How to get the View ID:
- Navigate to list/library settings
- At the bottom of the page you will see a view section, select the desired view
- In the URL you will see: View=%7B93B0D020%2D48DB%2D4881%2D984F%2D581DEFDF6D6C%7D&Source=
- Your ID is from the = until the &Source and again the ID needs some clean up.
- Remove %7B from the beginning of the URL. Remove %7D from the end of the URL. Replace all %2d to –
- Final View ID: 93B0D020-48DB-4881-984F-581DEFDF6D6C