Skip to main content

"Export to Spreadsheet" option in SharePoint list web part does not export all the columns

We all knew that the SharePoint list can be embedded in a web part page using the list web part. The list web part provides us with various properties which can be customized as per the requirement. One such property is the "Toolbar" . If "Show Toolbar" option is set, we would be provided with 3 tabs namely "New", "Actions" and "Settings". 

The list data can be exported to an excel using the "Export to Spreadsheet"  option found under the "Actions" tabs. 

Now here is the issue, suppose we have 10 columns in the list and we would like to show only 5 columns in the page, we would create a view in such a way that the page shows only the 5 columns.  If the data is exported from this page using the "Export to Spreadsheet" option, all the columns would definitely get exported, but the values would be exported only for those 5 columns which are shown on the page. This is because, the "Export to Spreadsheet" is taking only the display fields in the view instead of taking all the columns in the list.

User does not want to use the default list page where we have the "Export to Excel" option in the SharePoint Ribbon section. 

So what do we do? 

It's simple :) Place a custom "Export to excel" button on the page where the list view web part has been added. This would export all the data irrespective of the fields displayed in the view.

Please add the below html snippet to a content editor web part to create the "Export to excel" button on the page.

<button type="button" <a href"#" onclick="javascript:window.location='SITEURL/_vti_bin/owssvr.dll?CS=109&Using=_layouts/query.iqy&List={YOUR LIST ID}&View={YOUR VIEW ID}&CacheControl=1'">Export to Excel</a></button>

Please note that the LIST ID and VIEW ID are decoded ids. You may decode the IDs from here https://meyerweb.com/eric/tools/dencoder/


How to get the LIST and VIEW ID?? 

Please go to the list settings page and copy the URL,  you would get the LIST ID where the url would be like http://sharepoint.com/_layouts/15/listedit.aspx?List=LISTID.
Similarly, please click on the Views to get the VIEW ID.

Now the "Export to Excel" would work like a charm! 

Happy SharePointing!!! 





Comments

Popular posts from this blog

This site has exceeded its maximum storage limit.Error while uploading file to document library - SharePoint

Issue:  Unable to upload files to SharePoint document library irrespective of the document size. Solution: When you delete items from a SharePoint site, they're sent to the site Recycle Bin. When you delete items from a site Recycle Bin, they're sent to the site collection Recycle Bin.  A SharePoint site collection administrator can view and restore deleted items from the site collection Recycle Bin to their original locations. If an item is deleted from the site collection Recycle Bin, or it exceeds the retention time, it is permanently deleted. 1. Click the gear icon and go to the "Site Settings" page. 2. Under the Site Collection Administration, click on "Recycle bin". 3. Delete the unwanted files.

"An unexpected error has occurred. Changes to your data cannot be saved" excel SharePoint

“If you’re not making some notable mistakes along the way, you’re certainly not taking enough  business and career chances .” After creating a custom "Export to Excel" button on the SharePoint page as in my previous post:   https://nethrasb.blogspot.com/2020/05/export-to-spreadsheet-option-in.html we encountered an issue, where one of the user received "An unexpected error has occurred. Changes to your data cannot be saved" in the excel sheet to which the data has been exported. But I was able to export the data using "System Account" without any issue!  The user has full control over the site and there should not be any permissions related issues.  What could be the issue then?  It might seem silly but this is what happened. Humans make mistakes :) My fellow team mate who had been asked to create the view, created a "Personal" view instead of creating a "Public" view !  "Personal" view is i...