2.0.1 • Published 3 years ago
simple-js-export v2.0.1
- Quick & Simple export to CSV .
Note
V2 is still going on. See V1 for full functions.
Install
npm i simple-js-export
Example
const SimpleJsExport = require("simple-js-export")
const data = [...Array(100)].map((item, index) => {
return {
name: "name" + index,
code: "code" + index,
year: "year" + index,
}
})
const columns = [
{ title: "NAME", dataIndex: "name" },
{ title: "CODE", dataIndex: "code" },
{ title: "YEAR", dataIndex: "year" },
]
SimpleJsExport({ data, columns }).save()
Well, it seems a real trouble to set Column both title & dataIndex every time.
It is also allowed to set Only the title, provided that each item in the data has the same format content.
const SimpleJsExport = require("simple-js-export")
const data = [...Array(100)].map((item) => {
return {
name: "name" + item,
code: "code" + item,
year: "year" + item,
}
})
const columns = ["NAME", "CODE", "YEAR"]
SimpleJsExport({ data, columns }).save()
Option Properties
Property | Description | Required | Type | Default |
---|---|---|---|---|
data | Data to be exported into file | ✔ | Array | [] |
columns | Columns setting of datasource config | ✔ | Array | [] |
fileName | Filename to export | String | simple-js-export | |
delimiter | Delimiter | String | , |
Column
Property | Description | Required | Type | Default |
---|---|---|---|---|
title | Title of the column | ✔ | String | - |
dataIndex | Field of the data record | ✔ | String | - |
forceString | Date expected to be String type | Boolean | false |