4.0.1 • Published 3 months ago

vxe-table-plugin-export-pdf v4.0.1

Weekly downloads
83
License
MIT
Repository
github
Last release
3 months ago

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

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

Font

这里使用开源的 思源黑体

字体名称文件名
SourceHanSans-ExtraLightsource-han-sans-extralight.js
SourceHanSans-Lightsource-han-sans-light.js
SourceHanSans-Normalsource-han-sans-normal.js
SourceHanSans-Regularsource-han-sans-regular.js
SourceHanSans-Mediumsource-han-sans-medium.js
SourceHanSans-Boldsource-han-sans-bold.js
SourceHanSans-Heavysource-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

3.3.0

3 months ago

4.0.1

4 months ago

4.0.0

4 months ago

2.0.2

8 months ago

2.0.1

10 months ago

2.0.0

10 months ago

3.0.6

10 months ago

3.0.5

10 months ago

2.1.0

8 months ago

3.1.0

8 months ago

3.0.4

2 years ago

1.9.3

3 years ago

3.0.3

3 years ago

3.0.2

3 years ago

1.9.2

3 years ago

3.0.1

3 years ago

1.9.1

3 years ago

3.0.0

3 years ago

3.0.0-beta.1

3 years ago

3.0.0-beta.3

3 years ago

3.0.0-beta.2

3 years ago

3.0.0-beta.5

3 years ago

3.0.0-beta.4

3 years ago

3.0.0-beta.0

3 years ago

3.0.0-alpha.1

3 years ago

1.9.0

3 years ago

3.0.0-alpha.0

3 years ago

1.8.8

4 years ago

1.8.7

4 years ago

1.8.6

4 years ago

1.8.5

4 years ago

1.8.4

4 years ago

1.8.3

4 years ago

1.8.2

4 years ago

1.8.1

4 years ago

1.8.0

4 years ago

1.7.0

4 years ago

1.6.0

4 years ago

1.5.9

4 years ago

1.5.8

4 years ago

1.5.7

4 years ago

1.5.6

4 years ago

1.5.5

4 years ago

1.5.4

4 years ago

1.5.3

4 years ago

1.5.2

4 years ago

1.5.1

4 years ago

1.5.0

4 years ago

1.4.3

4 years ago

1.4.2

4 years ago

1.4.1

4 years ago

1.4.0

4 years ago

1.3.3

4 years ago

1.3.1

4 years ago

1.3.0

4 years ago

1.3.0-alpha.0

4 years ago

1.2.1

4 years ago

1.2.0

4 years ago

1.1.0

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

1.0.0-alpha.4

4 years ago

1.0.0-alpha.3

4 years ago

1.0.0-alpha.2

4 years ago

1.0.0-alpha.1

4 years ago