Kros的博客 Kros的博客
首页
  • CSS
  • 工具
  • Vue
  • js
  • Vue3
  • 算法
  • 折腾笔记
一言
  • 分类
  • 标签
  • 归档
码云

Kros

凡心所向,素履以往,生如逆旅,一苇以航
首页
  • CSS
  • 工具
  • Vue
  • js
  • Vue3
  • 算法
  • 折腾笔记
一言
  • 分类
  • 标签
  • 归档
码云
  • CSS

  • JavaScript

  • 工具

  • Vue

  • antdv踩坑记录

    • table左右fix后内容table和固定table出现错位
    • table同时存在额外展开行和固定列时固定列高度默认只有一行
    • antdv常见的全局提示框、弹框api调用
    • customRender实现行列合并
    • customRender中实现自定义渲染元素
    • antdv树结构table
    • table自定义空数据界面
    • mixin混入column时this指向问题
    • antdv日期组件显示英文
    • js导出页面上table
  • Vue3

  • 前端
  • antdv踩坑记录
kros
2022-03-02

js导出页面上table

先上代码:

// html 
<a-table id='tableTemp'>
	...
</a-table>

let tables = document.getElementById('tableTemp')
if (tables) {
    let exportFileContent = tables.getElementsByTagName('table')[0].outerHTML
    // 导出并添加表格样式和表头
    exportFileContent = `<html xmlns:x="urn:schemas-microsoft-com:office:excel"><head><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:WorksheetOptions><x:Print><x:ValidPrinterInfo /></x:Print></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml></head>
<style>
  table thead tr { height: 60px}
  table tbody tr { height: 60px}
</style>
<table><tbody><tr style="height: 80px; font-size: 18px"><th colspan="20">${name}</th></tr></tbody></table>
${exportFileContent}</html>`
    let blob = new Blob([exportFileContent], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' })
    var link = window.URL.createObjectURL(blob)
    var a = document.createElement('a')
    a.download = name + '.xlsx'
    a.href = link
    document.body.appendChild(a)
    a.click()
    document.body.removeChild(a)
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
上次更新: 2025/09/05, 8:09:00
antdv日期组件显示英文
vue3 setup语法糖

← antdv日期组件显示英文 vue3 setup语法糖→

最近更新
01
Find the next perfect square
09-05
02
Regex validate PIN code
09-05
03
Find the odd int
09-05
更多文章>
Theme by Vdoing | Copyright © 2020-2025 kros king
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式
icon-heart-o icon-heart icon-infinity icon-pause icon-play link next prev