export-csv
v1.0.1
Published
simple way for export csv
Downloads
285
Readme
export-csv
Artwork by i5ting.
Install
[sudo]npm install --save export-csv
Usages
默认使用gbk编码
var export_csv = require('.')
var data = [
{a:1,b:2},
{a:2,b:2},
{a:3,b:2}
]
export_csv(data, 'test1.csv')
过滤item,重写数据
var export_csv = require('.')
var data = [
{ a: 1, b: 2 },
{ a: 2, b: 2 },
{ a: 3, b: 2 }
]
export_csv(data, 'test3.csv', function (item) {
for (var key in item) {
item[key] = 'yy +' + item[key];
}
return item;
})
指定回调函数
var export_csv = require('.')
var data = [
{a:1,b:2},
{a:2,b:2},
{a:3,b:2}
]
export_csv(data, 'test2.csv', function (item) {
return item;
}, function () {
console.log('end...');
})
指定回调函数,并生成header
var export_csv = require('.')
var data = [
{a:1,b:2},
{a:2,b:2},
{a:3,b:2}
]
export_csv(data, 'test2.csv', function (item) {
return item;
}, function () {
console.log('end...');
}, true)
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
版本历史
- v1.0.0 初始化版本
欢迎fork和反馈
- write by
i5ting
[email protected]
如有建议或意见,请在issue提问或邮件
License
this repo is released under the MIT License.