• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

vxe-table-plugin-export-pdf: 基于 vxe-table 表格的增强插件,支持导出 pdf 格式 ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

vxe-table-plugin-export-pdf

开源软件地址:

https://gitee.com/x-extends/vxe-table-plugin-export-pdf

开源软件介绍:


vxe-table-plugin-export-pdf

gitee starnpm versionnpm downloadsnpm license

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

Installing

npm install xe-utils vxe-table@next vxe-table-plugin-export-pdf@next jspdf
// ...import VXETable from 'vxe-table'import VXETablePluginExportPDF from 'vxe-table-plugin-export-pdf'// ...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
// ...import VXETablePluginExportPDF from 'vxe-table-plugin-export-pdf'// ...VXETablePluginExportPDF.setup({  // Set default font  fontName: 'SourceHanSans-Normal',  // Font maps  fonts: [    {      // Font name      fontName: 'SourceHanSans-Normal',      // Font library url      fontUrl: 'https://cdn.jsdelivr.net/npm/vxe-table-plugin-export-pdf/fonts/source-han-sans-normal.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({        filename: 'MyExport',        type: 'pdf',        fontName: 'SourceHanSans-Normal' // Set font      })    }  }}

License

MIT © 2019-present, Xu Liangzhan


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap