增加 excel 导出的第一行标题选项 Former-commit-id: 66de20a3d02326759333a63a1f90e93834d7d420 [formerly 66de20a3d02326759333a63a1f90e93834d7d420 [formerly 66de20a3d02326759333a63a1f90e93834d7d420 [formerly 66de20a3d02326759333a63a1f90e93834d7d420 [formerly 3463e5feeaec05f84a8c42930edfbacaba6f0b92 [formerly 9ab91bc47458493d93f817aca80427749cb0acf6]]]]] Former-commit-id: 94df74e7c154789c835119fc23096fa6f8202ad5 Former-commit-id: 4a005fbd1ada5ce6e4cbb085b320660f2aa626cb Former-commit-id: 9d6dcc7b0e761e85a5295b235351b2e462c42f1f [formerly 607caf152de8bef7fede86a44e3003b1aaff2912] Former-commit-id: e54717456d4c5db124d9b8f0536a5dd6b1c9f8d7 Former-commit-id: 360f57cad825ce848e0cc1ef27835ec49837e0a8 Former-commit-id: 48de0f2794339a594d3fb37e3f76fdc6302932a9 Former-commit-id: e037bfa8bdb5e08b116cdea79887f82737b5034f Former-commit-id: e785e67cb2ee407b5b682bf8959767daff219ce7
64 lines
1.4 KiB
Vue
64 lines
1.4 KiB
Vue
<template>
|
|
<d2-container type="card">
|
|
<template slot="header">导出表格</template>
|
|
<div class="d2-mb">
|
|
<el-button type="primary" @click="exportCsv">
|
|
<d2-icon name="download"/>
|
|
导出 CSV
|
|
</el-button>
|
|
<el-button type="primary" @click="exportExcel">
|
|
<d2-icon name="download"/>
|
|
导出 Excel
|
|
</el-button>
|
|
</div>
|
|
<el-table v-bind="table" style="width: 100%">
|
|
<el-table-column
|
|
v-for="(item, index) in table.columns"
|
|
:key="index"
|
|
:prop="item.prop"
|
|
:label="item.label">
|
|
</el-table-column>
|
|
</el-table>
|
|
</d2-container>
|
|
</template>
|
|
|
|
<script>
|
|
// 假数据
|
|
import table from './data'
|
|
export default {
|
|
data () {
|
|
return {
|
|
table: {
|
|
columns: table.columns,
|
|
data: table.data,
|
|
size: 'mini',
|
|
stripe: true,
|
|
border: true
|
|
}
|
|
}
|
|
},
|
|
methods: {
|
|
exportCsv (params = {}) {
|
|
this.$export.csv({
|
|
columns: this.table.columns,
|
|
data: this.table.data
|
|
})
|
|
.then(() => {
|
|
this.$message('导出CSV成功')
|
|
})
|
|
},
|
|
exportExcel () {
|
|
this.$export.excel({
|
|
columns: this.table.columns,
|
|
data: this.table.data,
|
|
header: '导出 Excel',
|
|
merges: ['A1', 'E1']
|
|
})
|
|
.then(() => {
|
|
this.$message('导出表格成功')
|
|
})
|
|
}
|
|
}
|
|
}
|
|
</script>
|