generated from Leo_Ding/web-template
导出excel-xyq
This commit is contained in:
parent
d35912f728
commit
7ea530a34f
@ -44,10 +44,11 @@
|
|||||||
</a-card>
|
</a-card>
|
||||||
</a-col>
|
</a-col>
|
||||||
</a-row>
|
</a-row>
|
||||||
|
<div class="exportExcel"><a-button type="primary" @click="exportExcel">导出Excel</a-button></div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
|
import * as XLSX from "xlsx"; // 推荐用 xlsx 库导出 Excel
|
||||||
import { message, Modal } from 'ant-design-vue'
|
import { message, Modal } from 'ant-design-vue'
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import apis from '@/apis'
|
import apis from '@/apis'
|
||||||
@ -158,6 +159,23 @@ async function onOk() {
|
|||||||
await getPageList()
|
await getPageList()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function exportExcel() {
|
||||||
|
// 1. 创建一个工作簿
|
||||||
|
const wb = XLSX.utils.book_new();
|
||||||
|
// 2. 创建一个工作表
|
||||||
|
const ws = XLSX.utils.json_to_sheet(listData.value);
|
||||||
|
// 3. 将工作表添加到工作簿
|
||||||
|
XLSX.utils.book_append_sheet(wb, ws, "Sheet1");
|
||||||
|
// 4. 导出 Excel 文件
|
||||||
|
XLSX.writeFile(wb, "lotteryOrders.xlsx");
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="less" scoped></style>
|
<style lang="less" scoped>
|
||||||
|
.exportExcel {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
justify-content: right;
|
||||||
|
margin: 10px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user