Skip to content

save json as xls or csv in browser , and download . (在浏览器端将json转成xls/csv并下载)

License

Notifications You must be signed in to change notification settings

changgeee/save-json-as-excel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

save-json-as-excel

  • save json as xls or csv in browser , and download . (在浏览器端将 json 转成 xls/csv 并下载)
  • If the browser supports navigator.msSaveBlob or URL.createObjectURL, a Blob will be constructed and downloaded, otherwise Base64 encoded data will be downloaded. (如果浏览器支持 navigator.msSaveBlobURL.createObjectURL ,将构造一个 Blob 并下载,否则将下载Base64编码数据)

Install

  npm install save-json-as-excel --save

Usage

var dataSource = [
    {
      name: '海绵宝宝',
      age: 31,
      address: '贝壳街124号',
    },
    {
      name: '蟹老板',
      age: 75,
      address: '船锚路3541号',
    },
  ],
  columns = (columns = [
    {
      title: '姓名',
      dataIndex: 'name',
    },
    {
      title: '年龄',
      dataIndex: 'age',
    },
    {
      title: '住址',
      dataIndex: 'address',
    },
    {
      title: '出生年份',
      computed: function(item) {
        return 2017 - item.age;
      },
    },
  ]);

saveJsonAsExcel.saveAsXls(dataSource, columns, 'test.xls');
saveJsonAsExcel.saveAsCsv(dataSource, columns, 'test.csv');

License

  • save-json-as-excel is MIT licensed.

About

save json as xls or csv in browser , and download . (在浏览器端将json转成xls/csv并下载)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published