Rajesh
Rajesh 👨🏻‍💻developer, architect, consultant focussed on modernization, cognitive services, and conversational ai.

SharePoint Online Modern List - Export Selected Items to Excel

SharePoint Online Modern List - Export Selected Items to Excel

It has become a kind of tradition for me to write this component to export selected items to excel, whenever there is new model or approach of development in SharePoint. It all started with the SharePoint 2007 version. Here is the list of components for various versions and development models.

Lets look into this list view command set written in SharePoint Framework, it exports selected items to excel spreadsheet in xlsx format, with the columns from the current modern list view. This Listview extension utilizes SheetJS xlsx to create spreadsheet in xlsx format with the items selected from the view.

SharePoint Online Modern List - Export Selected Items to Excel

This extension illustrates the following concepts:

  • Export selected items to excel
  • Works across platforms
  • No need for additional plugins
  • No browser dependency
  • No IQY files
  • No additional sign-in required to render rows in spreadsheet
  • Exports only columns you see in the view

Where is source code

Source code is available here, at my github repo - https://github.com/rjesh-git/sp-dev-fx-extensions/tree/master/samples/js-command-selecteditems-export

Also created a PR to add it PnP SharePoint/sp-dev-fx-extensions hopefully it will be approved soon, and will update the above link accordingly

How to test in debug mode

  1. Clone this repository
  2. In the command line navigate to js-command-selecteditems-export and run:
  3. npm i
  4. gulp serve –nobrowser
  5. In a web browser, open any custom list
  6. Append the below debug url and press enter
  7. Choose Load Debug Scripts when prompted
  8. Add some sample list items (Be sure at least 1 item)
  9. Select the item, and export from toolbar
  10. Generates and downloads the xlsx file

How to deploy

I have not included any deployment scripts with this project, it’s a two step deployment process. Adding ListView Command Set - You can use feature framework, PnP provisioning template, or Office 365 CLI for adding the list view command set to the site Deploying SPFX Package - follow the steps as given here - https://docs.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/get-started/serve-your-web-part-in-a-sharepoint-page

Known Issue

Exports previous view columns, even after the view is changed. This is due to the limitation on using the legacyContext viewID property. Thanks @alexaterentiev for pointing it out.

comments powered by Disqus