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

tableconvertjs

v1.3.0

Published

将静态表格转换为自定义的格式,可以自定义多种表格读取方式,不限于xlsx

Downloads

10

Readme

xlsxconvert

介绍

将文档表格转换为自定义格式,目前只支持xlsx

用法

  1. 初始化配置

进入你要转表的目录,然后在此目录打开命令行工具。

输入 tablec init,可以生成最基本的配置

  1. 转表

用法1:

进入 tablec.json 所在的目录,然后在此目录打开命令行工具。

输入 tablec c,即可开始转表

用法2:

随意目录打开命令行工具

输入 tablec c=D:/static/table/tablec.json

转表配置

tablec.json

{
    "input": {
        "path": "",// 如果这里填了,则是输入表的路径
        "exportPrefix": "sh"// 需要导出的表明的前缀,即:sh的前缀的都导出
    },
    "output": [
        {
            "type": "json",
            "path": [
                "../output/json"/**导出json的路径,可以是字符串也可以是列表,为空则不导出json文件*/
            ],
            "dataSplit": 0,// (未实现)合并数据的方式,默认0; 1为数据和title分离
            "merge": [
                {
                    "files": [],//(未实现,先填空)文件分开组合
                    "compress": 1,//是否压缩
                    "path": "../output/json/allinone",//合并后的文件路径
                    "name": "data",//合并后的文件名
                    "nameExt": ".config",//合并后的文件扩展名
                    "branchSplit": 1// 是否要将不同的平台分开合并
                }
            ]
        },
        {
            "type": "ts",
            "path": [
                "../output/ts"/**导出ts的路径,可以是字符串也可以是列表*/
            ],
            "fileName": "sdata"/** 导出的ts的名字,不填默认为sdata*/
        },
        {
            "type": "cs",
            "path": "../output/cs",/**导出cs的路径,可以是字符串也可以是列表*/
            "fileName": "SysTableData",/** 导出的ts的名字,必须填*/
            "fileStart": "using System.Collections.Generic;\nnamespace xx {\n",/** 导出文件时,在文件头加的命名空间包裹 */
            "fileEnd": "\n}"
        }
    ],
    "tsOption": { /**导出ts时的设置,不设置则默认为以下设置*/
        "tablePrefix": "SeRes",/**ts导出的接口或类的前缀,一般后面是表名*/
        "typePrefix": "Se"/**ts导出类型的前缀,一般后面是Enum,Tags等...*/
    },
    "fontPath": "../output/font",/**文字去重后的导出txt文本路径,不设置则不导出font文件*/
    "errorLog": {/**如果检查出错的导出log,不设置则不导出log*/
        "check": true, /**是否检查错误*/
        "outputPath": "../output/errlog"/**错误输出路径,未输出则无错误*/
    },
    "plugin": {/** 使用本地自定义插件的设置,不设置则只会运行默认插件目录和自动插件目录,自动目录为json文件同级的plugins目录*/
        "path": "" /**指定插件的路径*/
    }
}

插件demo地址

表的规则

  1. 表格的第一行为:表头配置,使用alt+Enter可以在一行中,分为两行,这时,第二行可以使用附加内容

eg:primaryKey:true(表示是主键,每个表都需要主键);enum:枚举1|1|枚举2|2(表示枚举内容)

  1. 表格的第二行为:表头的注释

  2. 从第三行开始,为表的具体内容数据,如果是枚举或tags类型,填写枚举的中文(枚举列表用|分割开的0,2,4...的index位置的字符串)

如果是string[],Array<string>,number[]之类的,则可以用,隔开

  1. 如果是准备用于导出到cs的表,注意number需要改成int和float,支持int和float类型

  2. 增加了外部的全局Enum定义,在Enum表中定义一次,然后可以在其他的表里随意用定义好的名字

  3. 增加了外部的全局Json定义,在Json表中定义一次,然后其他的表里可以使用,包括列表

  4. 增加全局JsonCls定义,其他表里可以以:id:xx,num:2 的形式编辑,值类型目前只支持:int,float,number,string,以及其对应的列表

插件的规则

外部插件只需要实现start方法即可,为js文件

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Hello = void 0;
var Hello = /** @class */ (function () {
    function Hello(args) {
        this._convert = args;// 代码内调用时,默认会将转表类传入,其中缓存了所有表的源数据和转完后的数据集
    }
    Hello.prototype.start = function (data, callback) {
        console.log('hello',this._convert.convertCfg)// 这里拿到的是转表的配置
    };
    return Hello;
}());
exports.PlugIn = Hello; // 这里注意导出的名字是PlugIn

解析代码

查看代码包的core目录下