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 🙏

© 2026 – Pkg Stats / Ryan Hefner

exceljs-xlsx-template

v3.0.0

Published

Generate .xlsx file from .xlsx template. Support for Browser and Node.js

Readme

exceljs-xlsx-template

基于 exceljs 库的 .xlsx 模板文件填充引擎。理论上支持 exceljs 库的所有 api

  • 普通标签占位符格式:{{xxx}}{{xxx.xxx}}
  • 迭代标签占位符格式:{{@@xxx.xxx}}

支持浏览器和 node.js 环境下使用。可参考 test 目录下的 test.htmltest.js

<template>
  <button type="button" @click="handleXlsxTemplate">渲染xlsx模板</button>
</template>

<script setup lang="ts">
import { renderXlsxTemplate, placeholderRange } from "exceljs-xlsx-template";

function handleXlsxTemplate() {
  const xlsxFile =
    "https://raw.githubusercontent.com/cshaptx4869/exceljs-xlsx-template/refs/heads/main/test/assets/template.xlsx";
  const officialsealFile =
    "https://raw.githubusercontent.com/cshaptx4869/exceljs-xlsx-template/refs/heads/main/test/assets/officialseal.png";
  const imageUrl = "https://s2.loli.net/2025/03/07/ELZY594enrJwF7G.png";
  const data = [
    {
      name: "John",
      items: [
        { no: "No.1", name: "JavaScript" },
        { no: "No.2", name: "CSS" },
        { no: "No.3", name: "HTML" },
        { no: "No.4", name: "Node.js" },
        { no: "No.5", name: "Three.js" },
        { no: "No.6", name: "Vue" },
        { no: "No.7", name: "React" },
        { no: "No.8", name: "Angular" },
        { no: "No.9", name: "UniApp" },
      ],
      projects: [
        { name: "Project 1", description: "Description 1", image: imageUrl },
        { name: "Project 2", description: "Description 2", image: imageUrl },
        { name: "Project 3", description: "Description 3", image: imageUrl },
      ],
    },
    {
      invoice_number: "54548",
      last_name: "John",
      first_name: "Doe",
      phone: "00874****",
      invoice_date: "15/05/2008",
      items: [
        { name: "description", unit_price: 300 },
        { name: "HTML", unit_price: 400 },
      ],
      subtotal: 700,
      tax: 140,
      grand_total: 840,
    },
  ];

  try {
    renderXlsxTemplate(xlsxFile, data, `${Date.now()}.xlsx`, {
      parseImage: true,
      async beforeSave(workbook) {
        // 获取工作表
        const worksheet = workbook.getWorksheet("新报关单");
        if (worksheet) {
          // 加载图片印章
          const officialsealRresponse = await fetch(officialsealFile);
          if (!officialsealRresponse.ok) {
            console.error(`Failed to download image file, status code: ${officialsealRresponse.status}`);
            return;
          }
          const officialsealArrayBuffer = await officialsealRresponse.arrayBuffer();
          // 将图片添加到工作簿
          const imageId = workbook.addImage({
            buffer: officialsealArrayBuffer,
            extension: "png",
          });
          // 获取印章占位符位置信息
          const range = placeholderRange(worksheet, "{{#officialseal}}");
          if (range) {
            // 插入图片到表格中
            worksheet.addImage(imageId, {
              tl: { col: range.start.col, row: range.start.row - 4 },
              ext: { width: 200, height: 200 },
            });
          }
        }
      },
    });
  } catch (error) {
    console.error("Error processing Excel file:", error);
  }
}
</script>

input

output