function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Rohit Sharma 66Rohit Sharma 66 

Lightning, export to excel

Hi , 
I am working on Lightning, and trying to use export to excel in javascript controller.
I need to export data in two/three sheets of a single workbook. Like 1 sheet will contains open cases, 2nd sheet will contain closed cases etc.
I found few blogs but they are working fine to export data in one sheet, but I want to export data in multiple sheets of 1 workbook.
Can anyone plese help.
Mustafa JhabuawalaMustafa Jhabuawala
I haven't worked on any such requirement yet. But I can help you out.

Can you share the link of the blogs which you refered for exporting data in one sheet ?
Rohit Sharma 66Rohit Sharma 66
This is the blog i followed:

Mustafa JhabuawalaMustafa Jhabuawala

I visited the link. (

You can achieve this in two ways - 

Here I am refering the example shared in the above link.

Solution 1 -

You can divide the list in the controller method downloadCsv, seperate out the list data in whatever the number you want to download in the csv and then you can proceed further, you just need to repeat the code for each list of data.
var stockData = component.get("v.ListOfContact");
Iterate over this stockData and create multiple CSV by seperating the data.

Solution 2  -

Divide the data in the server side call itself in seperate list (in fetchContact method) and then send it to your JS controller. And then as it is done for a single CSV file you can do it for multiple file by reading multiple collections returned from server method call.

Let me know in case of any further clarification on this.

Mustafa Jhabuawala
Technical Lead at Zen4orce (
Rohit Sharma 66Rohit Sharma 66
Thanks Mustafa for the reply.

I already havinf two different list of records that i need to export in two sub sheet of an excel. But the approach u suggested exports the data in two seperate excel sheet. I need data to be export in two sub sheets for an excel sheet.
Talha SaqibTalha Saqib

I have written this guide with code that explains how to make an excel file in aura component: