1.0.1 • Published 6 years ago

castle-xlsx v1.0.1

Weekly downloads
3
License
ISC
Repository
github
Last release
6 years ago

castle-xlsx

npm i -S castle-xlsx

读取文件 read xlsx file in brower

<input type="file" name="" id="" @change="handleChange">
import { readAsJSON } from "castle-xlsx";
handleChange(e: any) {
    const files = e.target.files;
    if (!files) {
        return;
    }
    this.Loading = true;
    readAsJSON(files[0], (d: any) => {
        if (d["Sheet1"] instanceof Array) {
            this.XlsxData = d;
        } else {
            error("找不到Sheet1的表,请确认模版是否正确");
        }
        this.Loading = false;
    });
}

导出文件 export xlsx file in brower

从table中导出数据,数据源为table内容 export from table

    writeFileFronTable('table标签的id值, the table element`s id','文件名称 filename.xlsx')

从JSON数据导出为xlsx文件 export from json

    wirteFileFromJSON({
        SheetName:[
            {Title:1,Value:2},
            {Title:1,Value:2},
            {Title:1,Value:2},
            {Title:1,Value:2},
            {Title:1,Value:2},
            {Title:1,Value:2}
        ]
    },'文件名称 filename.xlsx')