MyGit

x-extends/vxe-table-plugin-export-pdf

Fork: 9 Star: 20 (更新于 2024-05-28 01:30:47)

license: MIT

Language: TypeScript .

🔨 基于 vxe-table 的表格插件,支持导出 pdf 格式

最后发布版本: 3.0.2 ( 2021-04-12 15:31:10)

GitHub网址

vxe-table-plugin-export-pdf

gitee star npm version npm downloads npm license

基于 vxe-table 的表格插件,支持导出 pdf 格式,基于 jspdf 实现

Compatibility

对应 vxe-table v4 版本

Installing

npm install vxe-table@next vxe-table-plugin-export-pdf@next jspdf
// ...
import VXETable from 'vxe-table'
import VXETablePluginExportPDF from 'vxe-table-plugin-export-pdf'
import { jsPDF } from 'jspdf'
// ...

// 方式1:NPM 安装,注入 jsPDF 对象
VXETable.use(VXETablePluginExportPDF, {
  jsPDF
})

// 方式2:CDN 安装,只要确保 window.jsPDF 存在即可
// VXETable.use(VXETablePluginExportPDF)

Options

属性 类型 描述 默认值
fontName String 设置默认的字体
fonts Array<{fontName, fontUrl}> 字体映射配置
beforeMethod Function({ $pdf, options, columns, datas }) 导出之前触发回调,可以自行设置字体等相关样式

Font

这里使用开源的 思源黑体

字体名称 文件名
SourceHanSans-ExtraLight source-han-sans-extralight.js
SourceHanSans-Light source-han-sans-light.js
SourceHanSans-Normal source-han-sans-normal.js
SourceHanSans-Regular source-han-sans-regular.js
SourceHanSans-Medium source-han-sans-medium.js
SourceHanSans-Bold source-han-sans-bold.js
SourceHanSans-Heavy source-han-sans-heavy.js

Demo

<vxe-toolbar>
  <template v-slot:buttons>
    <vxe-button @click="exportEvent">MyExport.pdf</vxe-button>
  </template>
</vxe-toolbar>

<vxe-table
  ref="xTable"
  height="600"
  :data="tableData">
  <vxe-column type="seq" width="60"></vxe-column>
  <vxe-column field="name" title="Name"></vxe-column>
  <vxe-column field="age" title="Age"></vxe-column>
  <vxe-column field="date" title="Date"></vxe-column>
</vxe-table>
export default {
  data () {
    return {
      tableData: [
        { id: 100, name: 'test', age: 26, date: null },
        { id: 101, name: 'test1', age: 30, date: null },
        { id: 102, name: 'test2', age: 34, date: null }
      ]
    }
  },
  methods: {
    exportEvent() {
      this.$refs.xTable.exportData({
        // fontName: 'SourceHanSans-Normal', // Set the font, default first
        filename: 'MyExport',
        type: 'pdf'
      })
    }
  }
}

License

MIT © 2019-present, Xu Liangzhan

最近版本更新:(数据更新于 2024-05-07 06:02:52)

2021-04-12 15:31:10 3.0.2

2021-03-23 23:25:00 1.9.2

2021-03-16 17:56:54 3.0.1

2021-03-16 09:50:34 3.0.0

2021-03-16 09:47:34 1.9.1

2020-11-16 10:03:47 1.9.0

2020-09-25 11:46:56 1.8.8

2020-09-16 19:29:32 1.8.7

2020-09-01 15:47:18 1.8.6

2020-08-15 20:51:50 1.8.5

x-extends/vxe-table-plugin-export-pdf同语言 TypeScript最近更新仓库

2024-07-03 11:29:30 immich-app/immich

2024-06-27 00:44:20 langfuse/langfuse

2024-06-25 21:34:23 ZuodaoTech/everyone-can-use-english

2024-06-25 02:22:22 typescript-eslint/typescript-eslint

2024-06-25 01:34:15 lobehub/lobe-chat

2024-06-21 17:44:25 janhq/jan