1. Products
  2.   Spreadsheet
  3.   Node.js
  4.   XLSX-Populate
 
  

Free Node.js Library to Create & Read Excel XLSX Files

Open Source Node.js Excel XLSX Parser/Generator enables Software Developers to Create, Modify, Validate, & Read Excel (.xlsx) Files in Node.js & Web Browser with Encryption Support.

XLSX files have long been a staple in the world of spreadsheets, providing a convenient way to store and manipulate data. When it comes to working with Excel files through code, the XLSX-Populate library is a standout tool. Made for JavaScript, XLSX-Populate lets developers build, edit, read, and manage Excel (.xlsx) files without needing MS Excel or other external software. This tool is handy for web apps that require creating reports, dashboards, or any tasks involving spreadsheets.

XLSX-Populate is a user-friendly library created to help you manage Excel XLSX files effortlessly. Its goal is to offer a straightforward yet robust interface for handling Excel files, catering to developers and programmers of all levels of expertise. Unlike other libraries that offer limited functions, this library supports a wide array of features, giving you complete command over Excel documents. You can create new Excel workbooks from scratch, add, remove, or rename worksheets, load existing .xlsx files, read from and write to individual cells, set cell formulas, style cells extensively, manage cell ranges, define data validation rules, apply conditional formatting, and more.

Working with XLSX-Populate is a breeze. It works seamlessly with both Node.js and web browsers, making it adaptable for various applications. Dealing with big Excel files can sometimes slow things down, but this tool is built to be fast and effective. It handles large sets of data well, ensuring tasks like reading, writing, and editing cells are done swiftly and without a hitch. In essence, this library is a top-notch resource for developers who need to work with Excel files through code. Its wide range of functions, user-friendly interface, and adaptability make it a great option for software experts and developers like you.

Previous Next

Getting Started with XLSX-Populate

The recommended way to install XLSX-Populate is using npm, please use the following script for a smooth installation.

Install XLSX-Populate via npm

npm install xlsx-populate

You can download the compiled shared library from GitHub repository and install it.

XLSX Workbook Creation and Modification in Node.js

The open source XLSX-Populate library has provided complete and robust functionality for creating new Excel workbooks from scratch as well as modifying existing ones inside Node.js applications. This includes the ability to add, rename, and delete worksheets within a workbook, giving users full control over the structure of their Excel XLSX files. Here is a very simple example that shows, how software developers can populate data in a workbook and access worksheet and cells within the workbook to manipulate them. Inside Node.js environment.

How to Load Data into a XLSX Workbook & Modify It via Node.js Library?

const XlsxPopulate = require('xlsx-populate');

// Load a new blank workbook
XlsxPopulate.fromBlankAsync()
    .then(workbook => {
        // Modify the workbook.
        workbook.sheet("Sheet1").cell("A1").value("This is neat!");

        // Write to file.
        return workbook.toFileAsync("./out.xlsx");
    });

Apply Style & Formatting to XLSX File in Node.js

Beyond basic cell values and formulas, the XLSX-Populate library excels in styling and formatting capabilities inside Node.js environment. Software Developers can merge cells, apply border styles, set cell alignment, as well as can apply rich text formatting within cells, including multiple fonts, colors, and styles in a single cell. Conditional formatting is also supported, which means you can dynamically change cell styles based on their values, making it easier to highlight important data trends and outliers. The following example demonstrates a simple code example for setting and getting a cell style inside Node.js applications.

How to Get/Set a Worksheet Cell Style inside Node.js Apps?

// Get a single style
const bold = cell.style("bold"); // true

// Get multiple styles
const styles = cell.style(["bold", "italic"]); // { bold: true, italic: true }

// Set a single style
cell.style("bold", true);

// Set multiple styles
cell.style({ bold: true, italic: true });

Worksheet Cell Manipulation in Node.js Apps

One of the core features of open source XLSX-Populate library is its extensive support for handling and manipulating data inside worksheet cell. Software Developers can easily set and get the value of cells, which can be numbers, strings, dates, or even rich text. Additionally, the library supports cell formatting, allowing for customization of font styles, sizes, colors, and more. This is essential for creating professional and readable spreadsheets. Here is a very useful example that shows how to set a cell to rich texts inside Node.js applications.

How to Set a Worksheet Cell to Rich Texts inside Node.js Apps?

const RichText = require('xlsx-Populate').RichText;
const cell = workbook.sheet(0).cell('A1');
// set a cell value to rich text
cell.value(new RichText());

// add two rich text fragments
cell.value()
    .add('hello ', { italic: true, bold: true })
    .add('world!', { fontColor: 'FF0000' });

Data Validation in Excel XLSX Files in Node.js

Data validation is a critical feature for ensuring data integrity and accuracy in Excel files. The open source XLSX-Populate library makes it easy for software developers to set data validation rules on cells inside their Node.js applications. This includes dropdown lists, numeric constraints, and other validation criteria that help prevent data entry errors. The following example shows, how software developer can set/get data validation inside Node.js environment.

How to Get/Set Data Validation on Excel XLSX Worksheet in Node.js Applications?

// Set the data validation
cell.dataValidation({
    type: 'list',
    allowBlank: false,
    showInputMessage: false,
    prompt: false,
    promptTitle: 'String',
    showErrorMessage: false,
    error: 'String',
    errorTitle: 'String',
    operator: 'String',
    formula1: '$A:$A',//Required
    formula2: 'String'
});

//Here is a short version of the one above.
cell.dataValidation('$A:$A');

// Get the data validation
const obj = cell.dataValidation(); // Returns an object

// Remove the data validation
cell.dataValidation(null); //Returns the cell