0.0.4 • Published 7 months ago

json2excel_convert v0.0.4

Weekly downloads
-
License
ISC
Repository
github
Last release
7 months ago

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-横向导出
    })
}

效果

  1. 纵向导出 img.png
  2. 横向导出 img.png

Notice

0.0.4

7 months ago

0.0.3

7 months ago

0.0.2

7 months ago

0.0.1

7 months ago