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

@sv-print/plugin-api-excel

v0.1.1

Published

add excel export api to print template

Readme

@sv-print/plugin-api-excel

为 sv-print 打印模板添加 Excel 导出功能,生成 .xlsx 格式文件,兼容 Microsoft Excel、WPS、LibreOffice、Google Sheets 等主流办公软件。

安装

npm install @sv-print/plugin-api-excel
# or
pnpm add @sv-print/plugin-api-excel

使用

import pluginApiExcel from "@sv-print/plugin-api-excel";

// 注册插件
hiprint.init([pluginApiExcel()]);

// 创建模板后即可使用 toExcel
let template = new hiprint.PrintTemplate(/* ... */);

// 下载 Excel 文件
template.toExcel(printData, { name: "导出文件名.xlsx" });

// 获取 Blob(不下载)
template.toExcel(printData, {
  isDownload: false,
  name: "report.xlsx",
}).then(blob => {
  // 处理 blob
});

API

template.toExcel(printData, options?)

参数:

| 参数 | 类型 | 说明 | |------|------|------| | printData | any | 打印数据 | | options | object | 可选配置项 |

选项:

| 选项 | 类型 | 默认值 | 说明 | |------|------|--------|------| | isDownload | boolean | true | 是否自动下载文件 | | name | string | sv-print-{timestamp}.xlsx | 下载文件名 | | fontName | string | Microsoft YaHei | 默认字体 | | fontSize | number | 10 | 默认字号(pt) | | sheetName | string | Sheet | 工作表名称前缀 | | pixelRatio | number | 1 | 非标准元素截图像素比 | | onProgress | (cur, total) => void | console.log | 进度回调 |

返回值: Promise<Blob> — Excel 文件的 Blob 对象

特性

  • 生成 .xlsx 格式(Office Open XML),最大兼容性
  • 表格元素:自动解析 HTML 表格结构,支持合并单元格(colspan/rowspan)、样式保留
  • 文本元素:提取文本内容及样式(字体、字号、加粗、颜色、对齐)
  • 图片元素:嵌入为 Excel 图片
  • 其他元素:通过 snapdom 截图转为图片嵌入(支持 ECharts、Fabric 等自定义元素)
  • 多面板/多页面自动创建多个工作表(Sheet)
  • 自动列宽适配