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

sy-excel2json

v1.1.4

Published

excel to json

Downloads

8

Readme

sy-excel2json

一个简单的将 .xlsx 转化输出为 .json 的工具

安装

npm i sy-excel2json -g

excel 内容示例

| key | 简体中文 | English | | :------ | -------- | ----------: | | title | 标题 | Title | | nav.home | 首页 | Home | | tip.success | 成功 | Success |

使用

outputType为object时,表格第一列用于生成对象的键,剩下的列用于生成值

sy-e2j filePath outputPath outputType [key1,key2...] [type1,type2,...]

filePath: 表示要转换的 .xlsx 文件路径

outputPath 表示转换后的 .json 文件路径

outputType 表示转换后的 .json 文件格式 目前支持数组(array)及对象(object) 类型,默认为array

key 表示表头(列名)转换后的键

type 表示列转换后值的类型
  type的可选类型为: string | number | boolean | date
  1. 直接使用(使用表头作为 key 的值)
  • 1.1 outputType为默认值:array
sy-e2j ./test.xlsx base
or
sy-e2j ./test.xlsx base.json

输出内容为:

[
  { "key": "title", "简体中文": "标题", "English": "Title" },
  { "key": "nav.home", "简体中文": "首页", "English": "Home" },
  { "key": "tip.success", "简体中文": "成功", "English": "Success" },
]
  • 1.2 outputType为object
sy-e2j ./test.xlsx base object
or
sy-e2j ./test.xlsx base.json object

输出内容为:

{
  "简体中文": {
    "title": "标题",
    "nav": {
      "home": "首页"
    },
    "tip": {
      "success": "成功"
    },
  },
  "English": {
    "title": "Title",
    "nav": {
      "home": "Home"
    },
    "tip": {
      "success": "Success"
    },
  }
}
  1. 使用自定义 key
  • 2.1 outputType为默认值:array
sy-e2j ./test.xlsx base array key,zh_CN,EN

输出内容为:

[
  {"key": "title", "zh_CN": "标题", "EN": "Title" },
  {"key": "nav.home", "zh_CN": "首页", "EN": "Home" },
  {"key": "tip.success", "zh_CN": "成功", "EN": "Success" },
]
  • 2.2 outputType为object
sy-e2j ./test.xlsx base object key,zh_CN,EN

输出内容为:

{
  "zh_CN": {
    "title": "标题",
    "nav": {
      "home": "首页"
    },
    "tip": {
      "success": "成功"
    }
  },
  "EN": {
    "title": "Title",
    "nav": {
      "home": "Home"
    },
    "tip": {
      "success": "Success"
    }
  }
}
  1. 使用自定义类型 若值类型为Number且该值无法转为Number时, 则为空字符串

| index | value | | :---- | ----: | | 1 | 11 | | 2 | | | 3 | 13 |

sy-e2j ./test.xlsx base array label,value string,number

输出内容为:

[
  { "label": "1", "value": 11 },
  { "label": "2", "value": "" },
  { "label": "3", "value": 13 }
]