npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

execljs-exporter-pro

v1.0.4

Published

Excel export helper based on ExcelJS

Readme

exceljs-exporter-pro

一个基于 ExcelJS 封装的 Excel 导出工具,适用于 Node.js / 后端服务 场景。
用于快速生成结构清晰、格式可控的 Excel 报表,支持复杂排版与数据写入需求。


✨ 特性

  • 支持多 Sheet 导出
  • 支持标题行(自动合并)
  • 表头行位置可配置
  • 支持普通数据行写入
  • 支持行级多段合并(精确到列)
  • 支持不合并单元格独立写值(合计 / 备注 / 公式)
  • 支持字体、背景色等样式
  • 自动设置列宽
  • 支持自定义输出目录
  • 支持 CommonJS 和 ESM 双模块引入

📦 安装

npm install exceljs-exporter-pro

示例

CommonJS

const exportExcel = require('exceljs-exporter-pro');


(async () => {
    const result = await exportExcel({
        fileName: '销售报表',
        outputDir: 'reports', // 输出目录(相对或绝对路径)
        sheets: [
            {
                title: '2025年12月销售数据', // 可选标题
                sheetName: 'Sheet1',        // 可选 sheet 名称
                headerRowIndex: 2,   // header 放到第 2 行
                header: ['商品', '数量', '金额'], // 表头行
                rows: [
                    ['笔记本', 10, 5000],
                    ['鼠标', 20, 800],
                    ['键盘', 5, 400]
                ],
                merges: [
                    {
                        row: 5,
                        cols: [
                            { start: 1, end: 3, value: '合计', style: { font: { bold: true } } }
                        ]
                    }
                ],
                cells: [
                    { row: 6, col: 'A', value: '备注', style: { font: { italic: true } } }
                ]
            },
            {
                sheetName: 'Sheet2',
                header: ['部门', '员工', '销售额'],
                rows: [
                    ['技术部', '张三', 12000],
                    ['销售部', '李四', 15000]
                ]
            }
        ]
    });

    console.log('文件生成成功:', result.filePath);
})();

ESM / TypeScript

import exportExcel from 'exceljs-exporter-pro';

const result = await exportExcel({
    fileName: '销售报表',
    outputDir: 'reports',
    sheets: [
        {
            title: '2025年12月销售数据',
            headerRowIndex: 2,   // header 放到第 2 行
            sheetName: 'Sheet1',
            header: ['商品', '数量', '金额'],
            rows: [
                ['笔记本', 10, 5000],
                ['鼠标', 20, 800],
                ['键盘', 5, 400]
            ],
            merges: [
                { row: 5, cols: [{ start: 1, end: 3, value: '合计' }] }
            ],
            cells: [
                { row: 6, col: 'A', value: '备注' }
            ]
        }
    ]
});

console.log('文件生成成功:', result.filePath);