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 🙏

© 2024 – Pkg Stats / Ryan Hefner

simple-xlsx-template

v1.1.111

Published

generate a new xlsx from a xlsx template

Downloads

24

Readme

simple-xlsx-template

在浏览器中根据xlsx模板生产xlsx并下载,还有pptx, docx

约定

  • 每个sheet用sheetN表示,比如sheet1, sheet2...

功能

  • 保留字段原来样式
  • 修改文本字段
  • 修改数值字段
  • 联动更新相关图表

不支持

  • 只支持修改字段,不支持新增
  • 不支持公式字段自动修改

安装

npm i simple-xlsx-template

使用

import patch_template from 'simple-xlsx-template'
import xlsx_url from './simple.xlsx'

const xlsx_data = {
    sheet1: {
        A1: '满意',
        B1: 45,
    },
}

const download_filename = 'demo.xlsx'

patch_template(xlsx_url, xlsx_data, download_filename)

支持pptx模板

约定

  • 每个slide用slideN表示,比如slide1, slide2...
  • 每个image用imageN表示,比如image1, image2...
  • 每个chart用chartN表示,比如chart1, chart2...

功能

  • 替换文本
  • 替换图片
  • 修改图表

不支持

  • 每个slide中的具体的image所对应的表示imageN是不确定的,需要尝试, 只有一个的话就用image1
  • 每个slide中的具体的chart所对应的表示chartN是不确定的,需要尝试, 只有一个的话就用chart1

使用pptx

import patch_template from 'simple-xlsx-template'
import pptx_url from './simple.pptx'
import image_url from './image2.png'

const pptx_data = {
    slide1: {
    	// 替换文本
        text: {
            'hello world': '你好世界',
        },
        // 替换图片
        image: {
            image1: image_url,
        },
        // 修改图表
        chart: {
            chart1: {
                sheet1: {
                    A2: '类型x',
                    B1: '系列y',
                    B2: 4.3,
                },
            },
        },
    },

}

const download_filename = 'demo.pptx'

patch_template(pptx_url, pptx_data, download_filename)

支持docx模板

约定

  • 每个image用imageN表示,比如image1, image2...
  • 每个chart用chartN表示,比如chart1, chart2...

功能

  • 替换文本
  • 替换图片
  • 修改图表

不支持

  • 具体的image所对应的表示imageN是不确定的,需要尝试, 只有一个的话就用image1
  • 具体的chart所对应的表示chartN是不确定的,需要尝试, 只有一个的话就用chart1

使用docx

import patch_template from 'simple-xlsx-template'
import docx_url from './simple.docx'
import docx_image_url from './docx-image2.png'

const docx_data = {
    text: {
        '非洲野生动物': '你好世界',
    },
    image: {
        image1: docx_image_url,
    },
    chart: {
        chart1: {
            sheet1: {
                A2: '类型x',
                B1: '系列y',
                B2: 660,
            },
        },
    },

}

const download_filename = 'demo.docx'

patch_template(docx_url, docx_data, download_filename)

如何开发

  1. 首选选定一个基础的版本,比如v1.xlsx、v1.pptx 或者 v1.docx
  2. 用编辑器修改部分数据,并另存为第二个版本,比如v2.xlsx、v2.pptx 或者 v2.docx
  3. 执行命令 ./diffxml.sh v1.xlsx v2.xlsx./diffxml.sh v1.pptx v2.pptx 或者 ./diffxml.sh v1.docx v2.docx
  4. 根据diffxml的结果,编写代码实现修改
  5. 打包到前端项目测试结果

目标

  • 简单优先
  • 稳定优先

证书

MIT