此文是介绍封装的工具函数的文档exportsFunction
特点: 扩展性高,调用灵活便捷
更多
- 通用函数 lazy-js-utils
- threejs简单化 s-three
- Echarts简单化 s-charts
- numsWheel 组件 s-nums-wheel
- vAxios 请求封装v-axios
使用说明
npm i exports-function # 安装
import {
jsonExportZip,
...
} from 'exports-function' # 按需引入
目录结构
00jsonExportZipjson导出为zip文件01tableExportExcelHTMLTableElement 转换为 Excel 导出02jsonExportExceljson导出成excel03exportPdf导出pdf
jsonExportZip
- jJson is exported as a zip file
- params:
- header: string[]
- data: any[][]
- fileName: string
jsonExportZip({
header: ['colums1', 'colums2', 'colums3'],
data: [
['data1', 'data2', 'data3'],
['data4', 'data5', 'data6'],
['data7', 'data8', 'data9'],
],
fileName: 'test',
})
tableExportExcel
- HTMLTableElement Convert to Excel export
- params:
- table: HTMLTableElement | string
- filename: string = 'test.xlsx
- sheetname: string = 'sheet1'
tableExportExcel('.my-table', 'table表格.xlsx') // Export the table .xlsx of the .my-table element
jsonExportExcel
- Json is exported to excel
- 参数:
- exportExcelOptions: { multiHeader?: [], header: [], data: any[][], filename?: string = 'excel-list', merges?: string[] = [], autoWidth: Boolean = false, bookType?: string = 'xlsx', sheetName?:string = 'sheet1', }
jsonExportExcel({
header: ['Name', 'Age', 'Gender'],
data: [
['Little King', '18', 'Male'],
['Little Lee', '20', 'Male'],
['Xiao Zhao', '21', 'male'],
['Xiao Zhang', '22', 'male'],
['Xiao Liu', '23', 'male'],
],
fileName: 'Information on students in the second class of the third year',
bookType: 'xlsx',
sheetName: 'Student Information Form',
}) // Export information .xlsx for students in the second class of the third year
exportPdf
- Export the pdf file
- params:
- src: Picture address
- filename: filename
exportPdf('./a.jpg', 'xxx') // Export xxx .pdf