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

js-xlsx-extended

v1.0.1

Published

fork了js-xlsx的功能,支持在用模板表格来生成自定义表格的时候可以保留样式

Downloads

3

Readme

介绍

这一个fork xlsx的库,是为了支持读取表格再生成的表格可以保留原有的样式

开始使用

npm i js-xlsx-extended
const XLSX = require('js-xlsx-extended') 

基本用法参考:SheetJS/xlsx

与xlsx的差异

1. 读取数据

在读取模版的时候拿到的workbook数据中 _s属性:每个sheet数据中的每个格子数据会有一个_s属性,这是一个样式映射的属性,有了_s就有样式。

_Views和_Cols:存在于模版数据的Workbook属性上,在复原样式的时候会用到这两个参数

2. 读取写入表格无其他操作

正常复原

3. 向sheet中追加数据

场景一:指定cell添加数据

比如给C4格设置数据并保留样式,需要将读取模版的对应sheet数据中的C4数据的_s属性值取出来设置到现在要添加的C4格数据上,有了_s就有样式

场景二:使用XLSX.utils.sheet_add_aoa方法添加数组数据

原sheet_add_aoa是不能保留样式的,需要使用新方法XLSX.utils.dz_sheet_add_aoa,使用和sheet_add_aoa方法一致

场景三:添加动态行数

因为有没有样式取决于表格数据中有没有_s,所以想要保留什么样的样式就去取模版对应cell数据中的_s,然后在添加数据的时候将_s参数加上即可

4. sheet追加sheet

原来:

XLSX.utils.book_append_sheet(
    'totalWorkbook',
    '要追加的sheet数据',
    '要追加的sheet名称'
  )

现在:

XLSX.utils.dz_book_append_sheet(
    'totalWorkbook',
    '要追加的sheet数据',
    '要追加的sheet名称',
    '要追加的workbook.Workbook',
    '要追加的workbook.Styles',
  )