Skip to content

Latest commit

 

History

History
83 lines (80 loc) · 1.43 KB

README.md

File metadata and controls

83 lines (80 loc) · 1.43 KB

基本使用

安装依赖

npm install exceljs
npm install file-saver

基本使用

import exportExcel from './export';

exportExcel({
    table:this.$refs.table
});

table

{
    table:tableDOM || tableOptions,
    images?:imagesOptions,
    backgroundImage?:backgroundImageOptions,
    sheetname?:'sheet1',
    filename?:'下载'
}

tables

{
    tables:tablesOptions,
    images?:imagesOptions,
    backgroundImage?:backgroundImageOptions,
    sheetname?:'sheet1',
    filename?:'下载'
}

sheets

{
    sheets:[{
        table?:tableDOM|| tableOptions,
        tables?:tablesOptions,
        sheetname?:'sheet1'
    }],
    filename?:'下载'
}

tableOptions

{
    el?:tableDOM,
    header?:,
    keys?:,
    data?:[],
    rowStyle?:({row,rowIndex,key,keyIndex})=>styleOptions,
    mergeCells?:({row,rowIndex,key,keyIndex})=>{colspan?:number,rowspan?:number,value?:string||number||({row,rows,rowIndex,key,keys,keyIndex})},
    space?:{left?:number,top?:number,right?:number,bottom?:number},//表格间隔
    origin?:'A1'||{col:number,row:number} // 定位到单元格
}

tablesOptions

[
    [tableDOM||tableOptions,tableDOM||tableOptions,...],
    [...],
    ...
]

imagesOptions

[{
    base64:'base64图片文件',
    range:string,// 例如:'B1:C8',
    extension?:'png'
}]

backgroundImageOptions

{
    base64:'base64图片文件',
    extension?:'png'
}