# xlsx-populator

> Tool for populating xlsx templates

Latest version **4.0.3** (published 2025-11-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install xlsx-populator
pnpm add xlsx-populator
yarn add xlsx-populator
bun add xlsx-populator
```

## Health

**Score 45/100 (D)** — status: stable.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; large bundle.

## Facts

| | |
|---|---|
| Version | 4.0.3 |
| Published | 2025-11-17 |
| First published | 2019-01-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 8 |
| Unpacked size | 18.2 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | victornikitin, jeffchen-png, dogusev, bpium, ruslangr, satoruf |
| Keywords | excel, workbook, xlsx, parse, generate, populate, template, formatting |

## Links

- npm: https://www.npmjs.com/package/xlsx-populator
- Repository: https://github.com/Bpium/xlsx-populator
- Homepage: https://github.com/Bpium/xlsx-populator#readme
- Issues: https://github.com/Bpium/xlsx-populator/issues
- npm.io page: https://npm.io/package/xlsx-populator

## Dependencies (8)

- [sax](https://npm.io/package/sax.md) >=0.6.0
- [lodash](https://npm.io/package/lodash.md) ^4.17.20
- [rimraf](https://npm.io/package/rimraf.md) ^2.6.3
- [core-js](https://npm.io/package/core-js.md) ^3.6.5
- [exceljs](https://npm.io/package/exceljs.md) ^4.4.0
- [traverse](https://npm.io/package/traverse.md) ^0.6.6
- [xmlbuilder](https://npm.io/package/xmlbuilder.md) ~9.0.1
- [regenerator-runtime](https://npm.io/package/regenerator-runtime.md) ^0.13.7

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 4.0.3 (latest) — 2025-11-17
- 4.0.2 — 2025-11-15
- 4.0.1 — 2025-11-14
- 4.0.0 — 2025-11-14
- 3.0.0 — 2025-11-11
- 2.3.7 — 2023-10-27
- 2.3.6 — 2022-06-23
- 2.3.5 — 2022-06-17
- 2.3.4 — 2021-03-31
- 2.3.3 — 2021-03-30
- 2.3.2 — 2021-02-25
- 2.3.1 — 2020-12-15
- 2.2.1 — 2020-12-15
- 2.3.0 — 2020-08-26
- 2.2.0 — 2020-08-10
- … 40 more at https://npm.io/package/xlsx-populator/versions

## README

# xlsx-populator
Library for populating xlsx templates with json data.
Array values will be automatically cloned

### Usage
1. add this module as dependency for you project
2. Use it, where you need 

    `const { xlsxPopulator } = require('xlsx-populator');`

3. Call `xlsxPopulator` with next arguments:

    * `inputFilePath` - relative, or absolute path to .docx file
    * `outputFilePath` - path, where populated .docx should appear
    * `dataObj` - JSON object with data

4. Promise will be returned with path to generated file

Usage example:
```
const handleDocx = (data, cb) => {
  const operationId = new Date().getTime();

  console.log('operationId', operationId);

  const dataObj = data.data;
  const docsPath = '/docs/' + operationId;
  const dirPath = 'public' + docsPath;
  fs.mkdir(dirPath, () => {

    const filePath = dirPath + '/input.docx';
    const file = fs.createWriteStream(filePath);
    const getFunction = data.template.match(/^https/) ? https.get : http.get;
    const request = getFunction(data.template, function(response) {
      response.pipe(file);
      file.on('finish', function() {
        file.close(() => {

          return xlsxPopulator(
            filePath,
            path.join(__dirname,'../',dirPath , '/outputdocx.docx'),
            dataObj)
            .resolve(cb);
        });

      });
    }).on('error', function(err) {
      console.log('! fail to load file', err);

      if (cb) cb(err.message);
    });

  });
};

```

---
_Source: https://npm.io/package/xlsx-populator · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
