json2excel_convert
v0.0.4
Published
将json数据导出为excel
Downloads
26
Maintainers
Readme
excelExport
将json数据导出为excel
广泛适配excel文件格式
可将json数据纵向导出为excel
可将json数据横向导出为excel
单元格列宽自适应
Install
npm install json2excel_convert
Examples
esm环境
import json2excel from 'json2excel_convert'
const xlsxData = [
{
"sheetName": "presdient_of_birthday",
"sheetData": [
{
"name": "George Washington"
},
{
"name": "John Adams",
},
{
"name": "John Adams",
},
{
"name": "Thomas Jefferson",
},
{
"name": "Aaron Burr",
}
]
}
]
function handleExport() {
json2excel({
fileName: 'presdient_birthday.xlsx',
data: xlsxData,
direction: 0 //0-纵向导出,1-横向导出
})
}
cjs环境
const json2excel = require('json2excel_convert')
const xlsxData = [
{
"sheetName": "presdient_of_birthday",
"sheetData": [
{
"name": "George Washington"
},
{
"name": "John Adams",
},
{
"name": "John Adams",
},
{
"name": "Thomas Jefferson",
},
{
"name": "Aaron Burr",
}
]
}
]
json2excel({
fileName: 'presdient_birthday.xlsx',
data: xlsxData,
direction: 0 //0-纵向导出,1-横向导出
})
umd环境
const xlsxData = [
{
"sheetName": "presdient_of_birthday",
"sheetData": [
{
"name": "George Washington"
},
{
"name": "John Adams",
},
{
"name": "John Adams",
},
{
"name": "Thomas Jefferson",
},
{
"name": "Aaron Burr",
}
]
}
]
function handleExport() {
json2excel({
fileName: 'presdient_birthday.xlsx',
data: xlsxData,
direction: 0 //0-纵向导出,1-横向导出
})
}
效果
- 纵向导出
- 横向导出