导出excel-xyq

This commit is contained in:
qingyu 2025-08-16 08:25:23 +08:00
parent d35912f728
commit 7ea530a34f

View File

@ -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>