Export selected items to excel - Office 365/NodeJS version

Sometime back, I wrote a full trust code to export selected items to excel. It was written in the form of custom action in ribbon and a layouts application page which handles the actual excel file creation and providing it as response. The layouts application page actually uses server side APIs in order to read the list item values. It works perfectly fine for the SharePoint 2010 and 2013 on-premises instances, now it has become kind of old-school method. Office 365 or SharePoint/Office 365-D model does not support any full trust code customization, so I decided to re-write this in a addin-model utilizing the client side REST APIs. When I started thinking about the addin-model, I found two available options for replacing the layouts application page. First, replace with a traditional way of using ASPX page residing in a provider hosted addin, the only difference between the earlier version and this model will be the server side APIs will be replaced by the REST APIs. I know its quiet achievable, and no big deal. Second option is to use NodeJS instead of IIS server, and use the JavaScript with the REST APIs. So this post is about the second option.


If you are Git person, directly fork or contribute from here.

Lets directly get into action and see how it works,


Custom action 

Use the below PowerShell CSOM script to add the custom action to your list, watch out for the hard coded url used in the form submit, you need replace it with your address of your nodeJS server.  

Addin Registration

In Azure portal, register your application and give read access on SharePoint sites. Note down the client ID and client secret. For more details on registering the application in Azure AD, refer this article.

NodeJS configurations

Update the below details in the parameters.json

Install node dependencies

  1. "adal-node": ">= 0.1.17"
  2. "express": "4.13"
  3. "connect-logger": "0.x"
  4. "cookie-parser": "1.4"
  5. "cookie-session": "2.x"
  6. "msexcel-builder": "0.0.2"
  7. "unirest": "2.14.x"
  8. "body-parser": "2.14.x"


  • Run the main.js in node to start the server. 
  • Your node instance is ready and starts listening the port configured. 
  • Go to your SharePoint Online site where the custom action has been added, and select few items in the list and select "export to excel' from the ribbon
  • An excel file will be downloaded with the file name same as your list name with the selected items as rows 
Peace! Happy Coding.


  1. We are using SharePoint Online and would love to use this solution. My apologies for not understanding your explanation on how to use this within the SharePoint Online environment. Would you be able to provide a quick walkthrough on how to apply your solution to the SharePoint Online environment?

    1. Specifically, we would like the solution to work like the previous 2010/2013 uses where they simply see the export to excel option in the ribbon, not run another program to do get it to work.

    2. Matthew, this article was targeted for developers who have NodeJS and Provider Hosted Addin model experience. Since SharePoint Online does not support full trust code (WSP) we need to use alternative options. Here NodeJS will be acting as the server. Answering to your comment, for implementing this in SharePoint Online you need to follow three steps.
      1. Register addin in Azure AD
      2. Add Export to excel to Ribbon
      3. Run Node JS (this can be your any server in On-Premises or in Azure)

  2. Manuuu1:46 AM

    Hi Rajesh,
    I had deplyed the abive farm solution and us working great for lust, libraries etc but nit for the issue tracking..Can you okease helo me in these..please approve and suggest a solution ..


Post a Comment