当前位置: 首页 > news >正文

聊城质量最好网站建设网站建设黄页免费观看

聊城质量最好网站建设,网站建设黄页免费观看,哈尔滨企业制作网站,电商运营必备技能Vxe UI vue vxe-table v4.8 与 v3.10 导出 xlsx、支持导出合并、设置样式、宽高、边框、字体、背景、超链接、图片等、所有常用的 Excel 格式都能自定义,使用非常简单,纯前端实现复杂的导出。 安装插件 npm install vxe-pc-ui4.2.39 vxe-table4.8.0 vx…

Vxe UI vue vxe-table v4.8+ 与 v3.10+ 导出 xlsx、支持导出合并、设置样式、宽高、边框、字体、背景、超链接、图片等、所有常用的 Excel 格式都能自定义,使用非常简单,纯前端实现复杂的导出。

安装插件

npm install vxe-pc-ui@4.2.39 vxe-table@4.8.0 @vxe-ui/plugin-export-xlsx@4.0.7 exceljs@4.4.0
// ...
import { VxeUI } from 'vxe-pc-ui'
import VxeUIPluginExportXLSX from '@vxe-ui/plugin-export-xlsx'
// ...VxeUI.use(VxeUIPluginExportXLSX)

在 index.html 引入对应的解析库,把对应的 js 下载到本地引入。

<script src="https://vxeui.com/umd/exceljs@4.4.0/dist/exceljs.min.js"></script>

默认导出

默认支持文本和单元格合并等导出,只需要开启对应的功能就可以直接使用了。
在这里插入图片描述

在这里插入图片描述

<template><div><vxe-button @click="exportEvent">高级导出</vxe-button><vxe-grid ref="gridRef" v-bind="gridOptions"></vxe-grid></div>
</template><script setup>
import { ref, reactive } from 'vue'const gridRef = ref()const gridOptions = reactive({border: true,showFooter: true,mergeCells: [{ row: 0, col: 2, rowspan: 2, colspan: 2 },{ row: 2, col: 1, rowspan: 3, colspan: 2 }],exportConfig: {type: 'xlsx'},columns: [{ field: 'seq', type: 'seq', width: 70 },{title: '分组1',children: [{ field: 'name', title: 'Name' },{ field: 'role', title: 'Role' }]},{ field: 'sex', title: 'Sex' },{ field: 'age', title: 'Age' }],data: [{ id: 10001, name: '张三', role: 'Develop', sex: 'Man', age: 28, address: 'test abc' },{ id: 10002, name: '李四', role: 'Test', sex: 'Women', age: 22, address: '广东省' },{ id: 10003, name: '王五', role: 'PM', sex: 'Man', age: 32, address: '上海' },{ id: 10004, name: '老六', role: 'Designer', sex: 'Women', age: 24, address: 'Shanghai' },{ id: 10005, name: '小七', role: 'Designer', sex: 'Man', age: 37, address: '广东省' },{ id: 10006, name: '小八', role: 'Designer', sex: 'Man', age: 39, address: 'Shanghai' }],footerData: [{ seq: '合计', name: '12人', no1: 356 }]
})const exportEvent = () => {const $grid = gridRef.valueif ($grid) {$grid.openExport()}
}
</script>

参数说明

通过 sheetMethod 自定义方法实现,参数说明 exportConfig.sheetMethod({
workbook 工作簿对象
worksheet 表对象
options 当前参数
})

自定义边框

在这里插入图片描述

<template><div><vxe-button @click="exportEvent">点击导出</vxe-button><vxe-grid ref="gridRef" v-bind="gridOptions"></vxe-grid></div>
</template><script setup>
import { ref, reactive } from 'vue'const gridRef = ref()const gridOptions = reactive({border: true,showFooter: true,exportConfig: {sheetMethod (params) {const { worksheet } = paramsworksheet.eachRow(excelRow => {excelRow.eachCell(excelCell => {// 设置单元格边框excelCell.border = {top: {style: 'thin',color: {argb: 'ff0000'}},left: {style: 'thin',color: {argb: 'ff0000'}},bottom: {style: 'thin',color: {argb: 'ff0000'}},right: {style: 'thin',color: {argb: 'ff0000'}}}})})}},columns: [{ field: 'seq', type: 'seq', width: 70 },{title: '分组1',children: [{ field: 'name', title: 'Name' },{ field: 'role', title: 'Role' }]},{ field: 'sex', title: 'Sex' },{ field: 'no1', title: 'NO1' },{ field: 'no2', title: 'NO2 String', cellType: 'string' }],data: [{ id: 10001, name: '张三', role: 'Develop', sex: 'Man', no1: '028', no2: '028' },{ id: 10002, name: '李四', role: '研发', sex: 'Women', no1: '220', no2: '220' },{ id: 10003, name: '王五', role: '产品经理', sex: 'Man', no1: '003200', no2: '003200' },{ id: 10004, name: '老六', role: 'Designer', sex: 'Women', no1: '02040', no2: '02040' }],footerData: [{ seq: '合计', name: '12人', no1: '356' }]
})const exportEvent = () => {const $grid = gridRef.valueif ($grid) {$grid.exportData({type: 'xlsx'})}
}
</script>

自定义字体

在这里插入图片描述

<template><div><vxe-button @click="exportEvent">点击导出</vxe-button><vxe-grid ref="gridRef" v-bind="gridOptions"></vxe-grid></div>
</template><script setup>
import { ref, reactive } from 'vue'const gridRef = ref()const gridOptions = reactive({border: true,showFooter: true,exportConfig: {sheetMethod (params) {const { worksheet } = paramsworksheet.eachRow(excelRow => {excelRow.eachCell(excelCell => {// 设置单元格字体excelCell.font = {bold: true,size: 16,color: {argb: 'ff0000'}}})})}},columns: [{ field: 'seq', type: 'seq', width: 70 },{title: '分组1',children: [{ field: 'name', title: 'Name' },{ field: 'role', title: 'Role' }]},{ field: 'sex', title: 'Sex' },{ field: 'no1', title: 'NO1' },{ field: 'no2', title: 'NO2 String', cellType: 'string' }],data: [{ id: 10001, name: '张三', role: 'Develop', sex: 'Man', no1: '028', no2: '028' },{ id: 10002, name: '李四', role: '研发', sex: 'Women', no1: '220', no2: '220' },{ id: 10003, name: '王五', role: '产品经理', sex: 'Man', no1: '003200', no2: '003200' },{ id: 10004, name: '老六', role: 'Designer', sex: 'Women', no1: '02040', no2: '02040' }],footerData: [{ seq: '合计', name: '12人', no1: '356' }]
})const exportEvent = () => {const $grid = gridRef.valueif ($grid) {$grid.exportData({type: 'xlsx'})}
}
</script>

自定义表头背景

在这里插入图片描述

<template><div><vxe-button @click="exportEvent">点击导出</vxe-button><vxe-grid ref="gridRef" v-bind="gridOptions"></vxe-grid></div>
</template><script setup>
import { ref, reactive } from 'vue'const gridRef = ref()const gridOptions = reactive({border: true,showFooter: true,exportConfig: {sheetMethod (params) {const { worksheet } = paramsworksheet.eachRow((excelRow, rowIndex) => {if (rowIndex <= 2) {excelRow.eachCell(excelCell => {// 填充单元格背景excelCell.fill = {type: 'pattern',pattern: 'solid',fgColor: {argb: 'c5d9f1'}}})}})}},columns: [{ field: 'seq', type: 'seq', width: 70 },{title: '分组1',children: [{ field: 'name', title: 'Name' },{ field: 'role', title: 'Role' }]},{ field: 'sex', title: 'Sex' },{ field: 'no1', title: 'NO1' },{ field: 'no2', title: 'NO2 String', cellType: 'string' }],data: [{ id: 10001, name: '张三', role: 'Develop', sex: 'Man', no1: '028', no2: '028' },{ id: 10002, name: '李四', role: '研发', sex: 'Women', no1: '220', no2: '220' },{ id: 10003, name: '王五', role: '产品经理', sex: 'Man', no1: '003200', no2: '003200' },{ id: 10004, name: '老六', role: 'Designer', sex: 'Women', no1: '02040', no2: '02040' }],footerData: [{ seq: '合计', name: '12人', no1: '356' }]
})const exportEvent = () => {const $grid = gridRef.valueif ($grid) {$grid.exportData({type: 'xlsx'})}
}
</script>

自定义列宽

覆盖默认的列宽
在这里插入图片描述

<template><div><vxe-button @click="exportEvent">点击导出</vxe-button><vxe-grid ref="gridRef" v-bind="gridOptions"></vxe-grid></div>
</template><script setup>
import { ref, reactive } from 'vue'const gridRef = ref()const gridOptions = reactive({border: true,showFooter: true,exportConfig: {async sheetMethod (params) {const { worksheet } = paramsworksheet.columns.forEach(sheetColumn => {// 设置列宽sheetColumn.width = 16})}},columns: [{ field: 'seq', type: 'seq', width: 70 },{title: '分组1',children: [{ field: 'name', title: 'Name' },{ field: 'role', title: 'Role' }]},{ field: 'sex', title: 'Sex' },{ field: 'no1', title: 'NO1' },{ field: 'no2', title: 'NO2 String', cellType: 'string' }],data: [{ id: 10001, name: '张三', role: 'Develop', sex: 'Man', no1: '028', no2: '028' },{ id: 10002, name: '李四', role: '研发', sex: 'Women', no1: '220', no2: '220' },{ id: 10003, name: '王五', role: '产品经理', sex: 'Man', no1: '003200', no2: '003200' },{ id: 10004, name: '老六', role: 'Designer', sex: 'Women', no1: '02040', no2: '02040' }],footerData: [{ seq: '合计', name: '12人', no1: '356' }]
})const exportEvent = () => {const $grid = gridRef.valueif ($grid) {$grid.exportData({type: 'xlsx'})}
}
</script>

自定义行高

覆盖默认的行高
在这里插入图片描述

<template><div><vxe-button @click="exportEvent">点击导出</vxe-button><vxe-grid ref="gridRef" v-bind="gridOptions"></vxe-grid></div>
</template><script setup>
import { ref, reactive } from 'vue'const gridRef = ref()const gridOptions = reactive({border: true,showFooter: true,exportConfig: {async sheetMethod (params) {const { worksheet } = paramsworksheet.eachRow((excelRow, rowIndex) => {// 设置行高excelRow.height = 60})}},columns: [{ field: 'seq', type: 'seq', width: 70 },{title: '分组1',children: [{ field: 'name', title: 'Name' },{ field: 'role', title: 'Role' }]},{ field: 'sex', title: 'Sex' },{ field: 'no1', title: 'NO1' },{ field: 'no2', title: 'NO2 String', cellType: 'string' }],data: [{ id: 10001, name: '张三', role: 'Develop', sex: 'Man', no1: '028', no2: '028' },{ id: 10002, name: '李四', role: '研发', sex: 'Women', no1: '220', no2: '220' },{ id: 10003, name: '王五', role: '产品经理', sex: 'Man', no1: '003200', no2: '003200' },{ id: 10004, name: '老六', role: 'Designer', sex: 'Women', no1: '02040', no2: '02040' }],footerData: [{ seq: '合计', name: '12人', no1: '356' }]
})const exportEvent = () => {const $grid = gridRef.valueif ($grid) {$grid.exportData({type: 'xlsx'})}
}
</script>

添加超链接

在这里插入图片描述

<template><div><vxe-button @click="exportEvent">点击导出</vxe-button><vxe-grid ref="gridRef" v-bind="gridOptions"></vxe-grid></div>
</template><script setup>
import { ref, reactive } from 'vue'const gridRef = ref()const gridOptions = reactive({border: true,showFooter: true,exportConfig: {sheetMethod (params) {const { worksheet } = paramsworksheet.eachRow((excelRow, rowIndex) => {if (rowIndex > 2) {excelRow.eachCell((excelCell, columnIndex) => {if (columnIndex === 2) {// 设置指定单元格为超链接excelCell.value = {text: `${excelCell.value}`,hyperlink: 'https://vxeui.com',tooltip: 'vxeui.com'}// 设置单元格字体excelCell.font = {color: {argb: '0000ff'}}}})}})}},columns: [{ field: 'seq', type: 'seq', width: 70 },{title: '分组1',children: [{ field: 'name', title: 'Name' },{ field: 'role', title: 'Role' }]},{ field: 'sex', title: 'Sex' },{ field: 'no1', title: 'NO1' },{ field: 'no2', title: 'NO2 String', cellType: 'string' }],data: [{ id: 10001, name: '张三', role: 'Develop', sex: 'Man', no1: '028', no2: '028' },{ id: 10002, name: '李四', role: '研发', sex: 'Women', no1: '220', no2: '220' },{ id: 10003, name: '王五', role: '产品经理', sex: 'Man', no1: '003200', no2: '003200' },{ id: 10004, name: '老六', role: 'Designer', sex: 'Women', no1: '02040', no2: '02040' }],footerData: [{ seq: '合计', name: '12人', no1: '356' }]
})const exportEvent = () => {const $grid = gridRef.valueif ($grid) {$grid.exportData({type: 'xlsx'})}
}
</script>

添加图片

图片支持 buffer 和 base64 格式。
在这里插入图片描述

<template><div><vxe-button @click="exportEvent">点击导出</vxe-button><vxe-grid ref="gridRef" v-bind="gridOptions"></vxe-grid></div>
</template><script setup>
import { ref, reactive } from 'vue'const gridRef = ref()const gridOptions = reactive({border: true,showFooter: true,exportConfig: {async sheetMethod (params) {const { worksheet, workbook } = params// 加载图片const buffer1 = await fetch('https://vxeui.com/logo.png').then(res => res.arrayBuffer())const imageId1 = workbook.addImage({buffer: buffer1,extension: 'png'})worksheet.eachRow((excelRow, rowIndex) => {if (rowIndex > 2) {// 设置行高excelRow.height = 60excelRow.eachCell((excelCell, columnIndex) => {if (columnIndex === 2) {// 将图片添加到单元格worksheet.addImage(imageId1, {tl: { col: columnIndex - 1, row: rowIndex - 1 },ext: { width: 40, height: 40 }})}})}})}},columns: [{ field: 'seq', type: 'seq', width: 70 },{title: '分组1',children: [{ field: 'name', title: 'Name' },{ field: 'role', title: 'Role' }]},{ field: 'sex', title: 'Sex' },{ field: 'no1', title: 'NO1' },{ field: 'no2', title: 'NO2 String', cellType: 'string' }],data: [{ id: 10001, name: '张三', role: 'Develop', sex: 'Man', no1: '028', no2: '028' },{ id: 10002, name: '李四', role: '研发', sex: 'Women', no1: '220', no2: '220' },{ id: 10003, name: '王五', role: '产品经理', sex: 'Man', no1: '003200', no2: '003200' },{ id: 10004, name: '老六', role: 'Designer', sex: 'Women', no1: '02040', no2: '02040' }],footerData: [{ seq: '合计', name: '12人', no1: '356' }]
})
const exportEvent = () => {const $grid = gridRef.valueif ($grid) {$grid.exportData({type: 'xlsx'})}
}
</script>

github https://github.com/x-extends/vxe-table
gitee

http://www.wooajung.com/news/31934.html

相关文章:

  • 网站添加百度统计代码吗网站建设哪家好公司
  • 西安做网站的网络公司站长之家站长工具综合查询
  • 开源门户网站源码沈阳线上教学
  • 正规网站建设百度站长平台网站收录
  • 做网站什么空间好站长统计幸福宝下载
  • 做网站一般长宽多少钱沈阳关键词推广
  • 建设银行网站登录入口长沙网站制作策划
  • 洞口做网站的公司免费b站推广网站2022
  • 官方网站搭建要多少钱百度贴吧人工客服
  • 一个dede管理两个网站seo网页的基础知识
  • 房产信息查询系统官方网站seo整站优化公司持续监控
  • 政府单位有必要网站建设吗网址大全2345
  • 电影网站权重怎么做设计外包网站
  • 网站制作优质公司seo什么意思简单来说
  • 网站备案多久一次seo排名的职位
  • 宜兴网站建设价格信息广告优化师适合女生吗
  • 科技公司网站制作模板百度知道登录入口
  • 两个网站链接如何做杭州seo排名收费
  • 做网站要考虑的百度电话客服24小时
  • 做旅游网站的方法时事新闻最新消息
  • 手机网店开店网站深圳网站seo地址
  • 做网站推广的公司最近几天的重大新闻事件
  • 电子商务网站建设也管理网络营销的发展趋势
  • 开封做网站哪家好站长工具seo综合查询官网
  • 网页图片加载不出来推广优化厂商联系方式
  • 聊城集团网站建设多少钱网络营销案例具体分析
  • 网站的手机版m站怎么做网络设计
  • 企业网站排名关键2023年5月份病毒感染情况
  • 怎么自己设计logoseo推广的常见目的有
  • 网站常见故障seo在线短视频发布页