Member-only story
Downloading data in excel format with Nest.js
In data organization , excel was and is a most acclaimed format . Even to this date when we have lots of database services still excel stands in between for storing or representing data in easy and facile way .
In Nest.js for writing the data in excel format we use a library named “exceljs”. Its a light-weight library used to manipulate , read or write the data into XLSX format. For more detail you can dive into documentation.
Prerequisite
Install Nest.js (node.js framework) globally using npm .
STEP 1:
Open your nest project in vs code and install following depedencies:
tmp library is used for creating temporary files and directories in nodejs environment.
STEP 2:
Head to your excel.service.ts file , write the following code
Import the following:
Using the sample data placed in data.ts file ,imported on line 2. The data format is :
Moving back to excel.service.ts , which contains the downloadExcel() function