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

mexcel

v0.0.4

Published

``` npm i mexcel ```

Downloads

11

Readme

mxlsx插件使用文档

npm i mexcel

excel导入

| 方法 | 描述 | 类型 | | ----------- | ----------- | ----------- | | importExcel | 导入 具体参数查看下方IExcelImportConfig | IExcelImportConfig |

| 参数 | 描述 | 类型 | 必填 | 可选值 | 默认值 | | ----------- | ----------- | ----------- | ----------- | ----------- | ----------- | | file | 文件 | File | Blob | 是 | -- | -- | | keys | 导入数据key值 | "A" | number | string[] | 否 | -- | -- | | keyRow | 读取excel表格中某行数据作为key值, keys 存在的情况下 keyRow 不生效 | number | 否 | -- | -- | | dataRow | 读取excel表格中从某行开始 | number | 否 | -- | 0 | | customKey | 是否采用自定义key keys、keyRow 和 dataRow 只有在 customKey 为 true 时才生效 | boolean | 否 | true | false | true | | onProgress | 导入文件进度 | (event: ProgressEvent) => void | 否 | -- | -- |

excel导出

| 方法 | 描述 | 类型 | | ----------- | ----------- | ----------- | | exportExcel | 导出 | (excelData: IExcel, path?: string, success?: () => void, fail?: (err: unknown) => void) => void |

参数说明

| 参数 | 描述 | 类型 | 必填 | 可选值 | 默认值 | | ----------- | ----------- | ----------- | ----------- | ----------- | ----------- | | fileName | 文件名 | string | 否 | -- | excel | | fileExtention | 文件格式 | string | 否 | xlsx | xls | xlsx | | sheets | 工作表数据工作表参数 | ISheet | 是 | -- | -- |

| 参数 | 描述 | 类型 | 必填 | 可选值 | 默认值 | | ----------- | ----------- | ----------- | ----------- | ----------- | ----------- | | title | 表格标题,自动合并单元格 | string | 否 | -- | -- | | titleStyle | 表格标题样式 具体参数查看下方单元格样式参数 在title存在的情况才生效 | CellStyle | 否 | -- | -- | | tHeaders | 表格表头 可以配置多表头,自动合并单元格 | INSArr[] | 否 | -- | -- | | tHeaderStyle | 表格表头样式 具体参数查看下方单元格样式参数 在tHeaders存在的情况才生效 | CellStyle | 否 | -- | -- | | table | 表格数据 | ITable[] | 是 | -- | -- | | cols | 列样式配置 具体参数查看下方列样式参数 | ColInfo[] | 否 | -- | -- | | titleRow | 表格标题行样式配置 行样式参数 在title存在的情况才生效 | RowInfo | 否 | -- | -- | | headerRows | 列样式配置 具体参数查看下方行样式参数 在tHeaders存在的情况才生效 | RowInfo[] | 否 | -- | -- | | row | 行样式配置 具体参数查看下方行样式参数 | RowInfo | 否 | -- | -- | | merges | 单元格合并配置 具体参数查看下方合并参数 | Range[] | 否 | -- | -- | | keys | 表格数据key值描述 参数数据影响标题和表头的自动合并 | INSArr | 是 | -- | -- | | sheetName | 工作表名字 | string | 否 | -- | sheet + 索引值 | | globalStyle | 单元格全局样式 具体参数查看下方单元格样式参数 | CellStyle | 否 | -- | -- | | cellStyle | 具体单元格自定义样式 具体参数查看下方单元格样式参数 | ICellStyle | 否 | -- | -- |

| 参数 | 描述 | 类型 | 必填 | 可选值 | 默认值 | | ----------- | ----------- | ----------- | ----------- | ----------- | ----------- | | font | 字体样式 具体参数查看下方字体样式参数 | CellStyle.font | 否 | -- | -- | | alignment | 对齐方式 具体参数查看下方对齐方式参数 | CellStyle.alignment | 否 | -- | -- | | border | 边框样式 具体参数查看下方边框样式参数 | CellStyle.border | 否 | -- | -- | | fill | 背景样式 具体参数查看下方背景样式参数 | CellStyle.fill | 否 | -- | -- | | numFmt | 数据格式 | string | 否 | 0 | 0.00% | 0.0% | 0.00%;\(0.00%\);\-;@ | m/dd/yy | 0 |

| 参数 | 描述 | 类型 | 必填 | 可选值 | 默认值 | | ----------- | ----------- | ----------- | ----------- | ----------- | ----------- | | bold | 粗细 | boolean | 否 | true | false | false | | color | 字体颜色 具体参数查看下方颜色参数 | CellStyleColor | 否 | -- | -- | | italic | 斜体 | boolean | 否 | true | false | false | | name | 字体 | string | 否 | -- | Calibri | | sz | 字体大小 | number | 否 | -- | -- | | strike | 删除线 | boolean | 否 | true | false | false | | underline | 下划线 | boolean | 否 | true | false | false | | vertAlign | 上下标 | string | 否 | "superscript" | "subscript" | null |

| 参数 | 描述 | 类型 | 必填 | 可选值 | 默认值 | | ----------- | ----------- | ----------- | ----------- | ----------- | ----------- | | horizontal | 横向对齐 | string | 否 | left | center | right | left | | vertical | 纵向对齐 | string | 否 | top | center | bottom | bottom | | textRotation | 文字旋转 | number | 否 | 0 - 180 | 255 | 0 | | wrapText | 是否换行 | boolean | 否 | true | false | false |

| 参数 | 描述 | 类型 | 必填 | 可选值 | 默认值 | | ----------- | ----------- | ----------- | ----------- | ----------- | ----------- | | top | 上边 具体参数查看下方颜色参数 边框属性参数 | { color: CellStyleColor; style?: BorderType } | 否 | -- | -- | | bottom | 下边 | { color: CellStyleColor; style?: BorderType } | 否 | -- | -- | | left | 左边 | { color: CellStyleColor; style?: BorderType } | 否 | -- | -- | | right | 右边 | { color: CellStyleColor; style?: BorderType } | 否 | -- | -- | | diagonal | 对角线 | { color: CellStyleColor; style?: BorderType; diagonalUp?: boolean; diagonalDown?: boolean } | 否 | -- | -- |

| 参数 | 描述 | 类型 | 必填 | 可选值 | 默认值 | | ----------- | ----------- | ----------- | ----------- | ----------- | ----------- | | bgColor | 背景色 具体参数查看下方颜色参数 | CellStyleColor | 否 | -- | -- | | fgColor | 前景色 具体参数查看下方颜色参数 | CellStyleColor | 否 | -- | -- | | patternType | 模式 | string | 否 | solid | none | solid |

| 参数 | 描述 | 类型 | 必填 | 可选值 | 默认值 | | ----------- | ----------- | ----------- | ----------- | ----------- | ----------- | | s | 开始单元格 具体参数查看下方表格位置参数 | CellAddress | 否 | -- | -- | | e | 结束单元格 具体参数查看下方表格位置参数 | CellAddress | 否 | -- | -- |

| 参数 | 描述 | 类型 | 必填 | 可选值 | 默认值 | | ----------- | ----------- | ----------- | ----------- | ----------- | ----------- | | c | 列数 | number | 是 | 0 - max | -- | | r | 行数 | number | 是 | 0 - max | -- |

| 参数 | 描述 | 类型 | 必填 | 可选值 | 默认值 | | ----------- | ----------- | ----------- | ----------- | ----------- | ----------- | | hidden | 是否隐藏行 | boolean | 否 | true | false | false | | hpx | 行高 屏幕像素高度 | number | 否 | 0 - max | -- | | hpt | 行高 以点为单位的高度 | number | 否 | 0 - max | -- | | level | 分组折叠 | number | 否 | -- | -- |

| 参数 | 描述 | 类型 | 必填 | 可选值 | 默认值 | | ----------- | ----------- | ----------- | ----------- | ----------- | ----------- | | hidden | 是否隐藏列 | boolean | 否 | true | false | false | | width | 列宽 最大数字宽度中的宽度 | number | 否 | 0 - max | -- | | wpx | 列宽 Excel的“最大数字宽度”中的宽度,width256是整数* | number | 否 | 0 - max | -- | | wch | 列宽 字符宽度 | number | 否 | 0 - max | -- | | level | 分组折叠 | number | 否 | -- | -- | | MDW | 列宽 Excel 的“最大数字宽度”单位,始终为整数 | number | 否 | 0 - max | -- |

| 参数 | 描述 | 类型 | 必填 | 可选值 | 默认值 | | ----------- | ----------- | ----------- | ----------- | ----------- | ----------- | | rgb | 颜色值 hex值不要带#号 | string | 否 | -- | -- | | theme | 主题色 theme与rgb不同时存在,theme覆盖rgb | number | 否 | -- | -- | | tint | 透明度 在theme存在是生效 | -1.0 - 1.0 | 否 | -- | -- |

| 描述 | 类型 | 必填 | 可选值 | 默认值 | | ----------- | ----------- | ----------- | ----------- | ----------- | | 边框样式 | BorderType | 否 | dashDot | dashDotDot | dashed | dotted | hair | medium | mediumDashDot | mediumDashDotDot | mediumDashed | slantDashDot | thick | thin | -- |

import { exportExcel, IExcel } from "mexcel";

const excelData: IExcel = {
    sheets: [
        {
            title: "学生列表",
            tHeaders: [["学号", "姓名", "班级", "考试成绩"], ["", "", "", "语文", "数学", "英语"]],
            merges: [
                {
                    s: { c: 0, r: 1 },
                    e: { c: 0, r: 2 }
                },
                {
                    s: { c: 1, r: 1 },
                    e: { c: 1, r: 2 }
                },
                {
                    s: { c: 2, r: 1 },
                    e: { c: 2, r: 2 }
                },
                {
                    s: { c: 3, r: 1 },
                    e: { c: 5, r: 1 }
                }
            ],
            table: [
                {
                    no: "1",
                    name: "李浩",
                    class: "二年级2班",
                    yuwen: 93,
                    shuxue: 95,
                    yingyu: 88
                },
                {
                    no: "2",
                    name: "王明",
                    class: "二年级1班",
                    yuwen: 89,
                    shuxue: 99,
                    yingyu: 90
                }
            ],
            cols: [
                {
                    wpx: 50
                },
                {
                    wpx: 100
                },
                {
                    wpx: 200
                },
                {
                    wpx: 50
                },
                {
                    wpx: 50
                },
                {
                    wpx: 50
                }
            ],
            titleRow: {
                hpx: 60
            },
            headerRows: [
                {
                    hpx: 40
                },
                {
                    hpx: 40
                }
            ],
            row: {
                hpx: 30
            },
            keys: ["no", "name", "class", "yuwen", "shuxue", "yingyu"],
            sheetName: "学生列表",
            globalStyle: {
                font: {
                    sz: 18
                },
                alignment: {
                    horizontal: "center",
                    vertical: "center",
                    wrapText: true
                },
                border: {
                    top: { style: "thin", color: {} },
                    right: { style: "thin", color: {} },
                    bottom: { style: "thin", color: {} },
                    left: { style: "thin", color: {} }
                }
            },
            titleStyle: {
                font: {
                    sz: 22,
                    color: {
                        rgb: "f60000"
                    }
                },
                alignment: {
                    horizontal: "center",
                    vertical: "center",
                    wrapText: true
                },
                border: {
                    top: { style: "thin", color: {} },
                    right: { style: "thin", color: {} },
                    bottom: { style: "thin", color: {} },
                    left: { style: "thin", color: {} }
                }
            }
        }
    ],
    fileName: "学生信息"
};

exportExcel(excelData);