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

easy-word

v1.1.1

Published

这是一个依赖docx插件,完成开发的word文档导出脚本,快速的导出word文档目前已经支持表格样式,图文样式

Readme

introduce

简单、快捷、方便地导出Word文档

这是一个依赖docx来实现的word文档的导出,现在已经支持表单、图形风格的导出,如果你不满足这些基本的风格,建议你去用docx定制开发来满足自己的风格。

安装/入门

npm i easy-word
npm i [email protected]

特别注意

项目依赖于docx, 同时你需要把你数据数组的图片全部转为base64并且封装在imgList参数里面, 同时把数据封装成统一格式才可以正确的识别.

import { outGraphic } from 'easy-word'  // 图文方法
import { outTable } from 'easy-word'   // 表格方法
import { Packer } from 'docx'
import { urlToBase64 } from 'easy-word' // 图片转base64方法 你也可以自己去封装

<!-- outGraphic(row, word)  -->
// 参数说明
 * @param {number} row 几行文字 max 10
 * @param {Array} data 数字数组 [{ 0 : val }]

// 比如我希望导出一个图文格式
{
  title: '',
  name: '',
  content: '',
  imgList: []
}

data = [{ 0: '标题', 1: '名字', 2: '内容', imgList: [] } ... ]
row = data[0].length - 1 =  3


<!-- 表格方法 -->
outTable(caption, row, data)
 @param {Array} caption 字符串数组 ['value1', 'value2'] 长度必等于 row - 1 
 @param {number} row  几行表格 max = 10
 @param {Array} data  key为数字value 为值的 数组 [{ 0: 'value', 1: 'vlaue' ... imgList: [] }]

大家可以把caption理解成表头,data 为表数据,
如表头为['班级', '姓名', '标题', '时间']
data 就为 [{ 0: '大一班', 1: '拉拉', 2: '标题内容', 3: '2022-5-11', imgList: ['base64...x'] }]
row = caption.length + 1 = 5

数据保持这样传入就可以得到正确的返回了


const doc:any = await outGraphic(row, word)
Packer.toBlob(doc).then(blob => {
    saveAs(blob, '图文文档.docx')
    console.log('开始保存')
  }).finally(() => {
    console.log('导出成功')
})

导出样式展示

表格文档 图文文档

发展

开发目的也是为了练习npm包制作流程和对docx文档导出的方法记录.后续可能会断断续续记录 word文档的导出模板样式.目前先测试测试,后续支持文字颜色字体,边框的diy,现在还没有写参数...

特性

这个项目能做什么呢?

  • word文档的导出
  • 支持图文wrod导出
  • 支持基础表格导出