Guide · Open source
How to use exceljs: install and read or write Excel files in Node.js
Updated · written with AI from the project's own documentation and checked against our catalogue data
ExcelJS is an open-source JavaScript package that lets a program read, manipulate and write spreadsheet data and styles in XLSX format. This guide covers what it is, how to install it with npm, and how it fits into a Node.js project. After reading, you will know whether it suits your task and how to start generating or processing Excel files in code.
Quick start
- 1Check Node.js is installed. ExcelJS requires Node.js. Confirm it is available on your machine before installing the package.
- 2Install the package. Run npm install exceljs in your project folder.
- 3Import ExcelJS in your code. Load the package in your JavaScript file so you can create or read workbooks.
- 4Create a workbook and worksheet. Create a new workbook and add a worksheet to hold your rows of data.
- 5Fill the worksheet with data. Add rows from your application data and set any styles you need.
- 6Save or read the file. Write the workbook to an XLSX file, or read an existing XLSX file into code for processing.
What ExcelJS is and who it is for
ExcelJS is a code library, not a spreadsheet application. You use it from JavaScript to create, read and change Excel files, including cell data and styles. The project describes itself as reading, manipulating and writing spreadsheet data and styles to XLSX and JSON.
It is aimed at Node.js developers who need to generate Excel reports from application data, read spreadsheet data into code, or automate exports and imports. Its topics list streaming workbook support, which is relevant when you work with large files.
- Good fit: generating reports from application data
- Good fit: reading spreadsheet data and processing it in code
- Not a fit: opening or editing a spreadsheet by hand
- Not a fit: legacy binary .xls files, since the README focuses on XLSX
Install ExcelJS with npm
The only prerequisite named in the source is Node.js. Install the package with npm from your project folder.
npm install exceljsCreate a workbook and write data
Once the package is installed, your code creates a workbook, adds a worksheet, and fills it with rows. The README's Contents list includes sections on creating a workbook, adding a worksheet, and working with worksheet properties and page setup, which you can read in the full documentation for exact method names.
Save the result to a file when you are done so the generated report can be opened in Excel or another spreadsheet program.
- Create a workbook
- Add a worksheet
- Set worksheet properties and page setup as needed
Read and process an existing spreadsheet
ExcelJS can also read XLSX files into code so you can process the values. Reading is useful for imports, where a spreadsheet supplied by a user or partner needs to be checked and loaded into an application.
For very large workbooks, the topics list streaming support. Check the streaming section of the documentation before choosing how to load a big file.
Know the limits before you start
ExcelJS is focused on XLSX. If you need legacy binary .xls files, the README does not cover them, so look at a comparable project instead. Using the library requires writing JavaScript, so it is not a option for people who only want to edit a sheet by hand.
The README also notes that a pivot table feature was merged with limitations, so check the documentation for exactly what is supported.
What people use it for
- Generating monthly Excel reports from application data
- Exporting database records to a spreadsheet for users
- Importing spreadsheet data supplied by a partner and processing it in code
- Automating recurring spreadsheet exports or imports in a Node.js service
- Processing large workbooks with streaming support
Frequently asked questions
How do I install exceljs?
Run npm install exceljs in your project folder. Node.js is the only prerequisite named in the source, so make sure it is installed first.
Is exceljs free to use?
ExcelJS is released under the MIT licence. The source states that contributions are included in that MIT licence.
Does exceljs support xls files?
The README focuses on XLSX, and the source does not say it handles legacy binary .xls files. If you need .xls, consider a comparable project such as SheetJS.
Do I need to know JavaScript to use exceljs?
Yes. ExcelJS is a code library, and using it requires writing JavaScript. People who only want to edit a spreadsheet by hand should use a spreadsheet application.
Can exceljs handle large files?
The project's topics list streaming workbook support, which is intended for large workbooks. Check the streaming section of the documentation for how to use it.
How does exceljs compare to SheetJS, xlsx-populate or node-xlsx?
The source lists these as comparable projects but does not benchmark them, so this page makes no claim about which is faster or better. Compare their documented features against your needs, such as XLSX support and streaming.
New agent skills, repos and AI tools — every week
The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.
Our verdict
ExcelJS suits Node.js developers who need to generate or process XLSX spreadsheets from application data, with streaming for large files. It is a poor choice for people who want to edit spreadsheets by hand, need legacy .xls files, or do not write code.
Install options & downloads