/*
 * @Author: LiZhiWei
 * @Date: 2025-04-09 10:49:05
 * @LastEditors: LiZhiWei
 * @LastEditTime: 2025-04-23 17:45:30
 * @Description:
 */
import ExcelJS from 'exceljs'
import { createApp } from 'vue'
import Table from './Table.vue'
import 'x-data-spreadsheet/dist/xspreadsheet.css'

/**
 * 渲染excel
 */
export default async function render (buffer, target) {
  const workbook = await new ExcelJS.Workbook().xlsx.load(buffer)
  const app = createApp(Table, { workbook })
  app.mount(target)
  return {
    $el: target,
    $destroy() {
      app.unmount()
    }
  }
}
