1.0.2 • Published 3 years ago

girf-export-excel v1.0.2

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

优化 iViewUI 中 Table 导出功能:增加 xlsx 后缀格式支持

安装

npm i girf-export-excel

或

yarn add girf-export-excel

使用

  • template 部分

    <template>
      <div>
          ...
          <a href="javascript:void(0)" @click="exportData()">导出</a>
          <!-- 组件:导出数据到Excel表格-->
          <excel-export :params="componentExcelExport.params"></excel-export>
          ...
      </div>
    </template>
    
    <script>
    import ExcelExport from 'girf-export-excel'
    
    export default {
    
        components: { 
            ExcelExport 
        },
    
        data () {
    
            return {
    
              // 组件:Excel导出配置
              componentExcelExport: {
    
                  params: {
                      start: false,   // 导出开始
                      data: [],       // 导出需要的数据
                      name: ''        // 导出名称
                  }
              }
    
            }
        },
    
        methods: {
    
            exportData() {
    
              let _data = [ { title: '标题', type: '类别', count: '浏览量', times: '时间', status: '状态' } ]
    
              _data.push({ title: '长颈鹿英语ABC', type: '英语', count: 100, time: '2020-03-11', status: '已读' })
              _data.push({ title: '长颈鹿英语EFG', type: '英语', count: 100, time: '2020-03-11', status: '已读' })
    
              let _name = '数据-'+ new Date().valueOf()
    
              this.componentExcelExport.params = { start: true, data: _data, name: _name }
            }
        }
    }
    </script>

    参数

    KeyDesc
    params参数配置,类型 Object
    params.start使用导出功能的开关,类型 Bool
    params.data导出的数据,类型 Array第一条数据是表头,其他都为实际数据
    params.name导出文件名,类型 String,无需后缀
1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago