table-to-csv
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

环境说明:

该组件是原生js编写,支持typescript; 在浏览器环境中使用,不区分 vue, react等框架环境

详细说明:

https://www.cnblogs.com/yalong/p/15214644.html

安装

npm i table-to-csv -S

使用示例

import TableToCsv from 'table-to-csv';
const initColumns = [
  {
    dataIndex: "Index",
    key: "Index",
    title: "序号",
  },
  {
    dataIndex: "userid",
    key: "userid",
    title: "用户Uid",
  },
  {
    dataIndex: "score",
    key: "score",
    title: "收益点",
  }
 ]
 const initList = [
    {
      id: '32',
      Index: 1,
      userid: '11',
      score: '10'
    },
    {
      id: '42'
      Index: 2,
      userid: '22',
      score: '20'
    },
    {
      id: '89',
      Index: 3,
      userid: '33',
      score: '30'
    }
  ];

 TableToCsv(initColumns, initList, '统计表格')

说明:

  • initColumns 就是 table 列的数据
  • initList 就是 table 的展示数据
  • 第三个参数就是下载文件的名字
  • initColumns 里面keydataIndex 必须有一个

Readme

Keywords

Package Sidebar

Install

npm i table-to-csv

Weekly Downloads

1

Version

0.1.1

License

MIT

Unpacked Size

3 kB

Total Files

4

Last publish

Collaborators

  • yanyalong