使用 vxe-table 来格式化任意的金额格式,支持导出与复制单元格格式到 excel

使用 vxe-table 来格式化任意的金额格式,支持导出与复制单元格格式到 excel

查看官网:https://vxetable.cn
gitbub:https://github.com/x-extends/vxe-table
gitee:https://gitee.com/x-extends/vxe-table

安装

npm install vxe-pc-ui@4.5.23 vxe-table@4.13.4
import VxeUIAll from 'vxe-pc-ui'
import 'vxe-pc-ui/lib/style.css'
import VxeUITable from 'vxe-table'
import 'vxe-table/lib/style.css'createApp(App).use(VxeUIAll).use(VxeUITable).mount('#app')

格式化金额

通过内置的 FormatNumberInput 格式化数值渲染器,配置 type = amount 为货币类型就可以了

在这里插入图片描述

<template><div><vxe-grid v-bind="gridOptions"></vxe-grid></div>
</template><script setup>
import { reactive } from 'vue'const gridOptions = reactive({border: true,height: 500,showOverflow: true,columns: [{ type: 'seq', width: 60 },{ field: 'name', title: '名字' },{ field: 'num1', title: '货币类型', align: 'right', cellRender: { name: 'FormatNumberInput', props: { type: 'amount', align: 'right' } } },{ field: 'num2', title: '货币类型(带货币符号)', align: 'right', cellRender: { name: 'FormatNumberInput', props: { type: 'amount', align: 'right', showCurrency: true } } },{ field: 'num3', title: '货币类型(负数自动标红)', align: 'right', cellRender: { name: 'FormatNumberInput', showNegativeStatus: true, props: { type: 'amount', align: 'right', showCurrency: true } } }],data: [{ id: 10001, name: '张三', code1: '0002365', code2: '0002365', num1: -3.56, num2: -3.56, num3: -3.56, num4: -3.56, str1: '10,000,000.00', str2: '10,000,000.00' },{ id: 10002, name: '李四', code1: '0002465', code2: '0002465', num1: 1, num2: 1, num3: 1, num4: 1, str1: '90,000,000.00', str2: '90,000,000.00' },{ id: 10003, name: '老六', code1: '0002567', code2: '0002567', num1: 1235640, num2: 1235640, num3: 1235640, num4: 1235640, str1: '100,000', str2: '100,000' },{ id: 10004, name: '小李', code1: '0678865', code2: '0678865', num1: -96300000.4, num2: -96300000.4, num3: -96300000.4, num4: -96300000.4, str1: '', str2: '' },{ id: 10005, name: '老万', code1: '23470565', code2: '23470565', num1: 240.63, num2: 240.63, num3: 240.63, num4: 240.63, str1: '', str2: '' },{ id: 10006, name: '小刘', code1: '086222135', code2: '086222135', num1: 0.1, num2: 0.1, num3: 0.1, num4: 0.1, str1: '', str2: '' },{ id: 10007, name: '老徐', code1: '3600665', code2: '3600665', num1: 0, num2: 0, num3: 0, num4: 0, str1: '330.02', str2: '330.02' },{ id: 10008, name: '老二', code1: '009635', code2: '009635', num1: null, num2: null, num3: null, num4: null, str1: '10,000,000.33', str2: '10,000,000.33' },{ id: 10009, name: '小牛', code1: '09034523', code2: '09034523', num1: 100000000, num2: 100000000, num3: 100000000, num4: 100000000, str1: '', str2: '' },{ id: 10010, name: '小帅', code1: '872220222', code2: '872220222', num1: null, num2: null, num3: null, num4: null, str1: '1,230.30', str2: '1,230.30' },{ id: 10011, name: '老魏', code1: '10022354', code2: '10022354', num1: 96342, num2: 96342, num3: 96342, num4: 96342, str1: '', str2: '' },{ id: 10012, name: '小徐', code1: '0009785', code2: '0009785', num1: -740000, num2: -740000, num3: -740000, num4: -740000, str1: '', str2: '' }]
})
</script>

导出到 excel

支持导出分组表头、合并、单元格类型、导出图片等格式
在这里插入图片描述

<template><div><vxe-button status="primary" @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 imgUrlCellRender = reactive({name: 'VxeImage',props: {width: 36,height: 36}
});const gridOptions = reactive({border: true,showFooter: true,showOverflow: true,editConfig: {trigger: 'click',mode: 'cell'},mergeCells: [{ row: 0, col: 2, rowspan: 1, colspan: 2 },{ row: 2, col: 2, rowspan: 2, colspan: 1 }],exportConfig: {type: 'xlsx'},columns: [{ field: 'checkbox', type: 'checkbox', width: 70 },{ field: 'seq', type: 'seq', width: 70 },{ field: 'name', title: 'Name', editRender: { name: 'VxeInput' } },{ field: 'code', title: '字符串类型', cellType: 'string', editRender: { name: 'VxeInput' } },{title: '分组1',children: [{ field: 'num1', title: '数值', editRender: { name: 'VxeNumberInput', props: { type: 'float' } } },{ field: 'num2', title: '数值(负数标红)', editRender: { name: 'VxeNumberInput', showNegativeStatus: true, props: { type: 'float' } } }]},{ field: 'amount1', title: '货币', editRender: { name: 'VxeNumberInput', props: { type: 'amount', showCurrency: true } } },{ field: 'amount2', title: '货币(负数标红)', editRender: { name: 'VxeNumberInput', showNegativeStatus: true, props: { type: 'amount', showCurrency: true } } },{ field: 'imgUrl', title: '图片', width: 80, cellRender: imgUrlCellRender }],data: [{ id: 10001, name: '张三', code: '000528697411', num1: 0.32, num2: -0.11, amount1: 1000000000, amount2: -0.11, imgUrl: 'https://vxeui.com/resource/img/fj586.png' },{ id: 10002, name: '李四', code: '001236598563', num1: null, num2: 100000, amount1: -990000, amount2: 4, imgUrl: 'https://vxeui.com/resource/img/fj573.jpeg' },{ id: 10003, name: '王五', code: '001499675653', num1: 100000, num2: null, amount1: 1, amount2: 100000, imgUrl: 'https://vxeui.com/resource/img/fj567.jpeg' },{ id: 10004, name: '老六', code: '002568967545', num1: -0.11, num2: 1000000000, amount1: null, amount2: 1000000000, imgUrl: 'https://vxeui.com/resource/img/fj577.jpg' },{ id: 10005, name: '小七', code: '005233368777', num1: -990000, num2: 28, amount1: 100000, amount2: null, imgUrl: 'https://vxeui.com/resource/img/bq673.gif' },{ id: 10006, name: '小八', code: '000369877575', num1: 1000000000, num2: -990000, amount1: -0.11, amount2: -990000, imgUrl: 'https://vxeui.com/resource/img/fj124.jpeg' }],footerData: [{ checkbox: '合计', name: '12人', no1: 356 }]
});const exportEvent = () => {const $grid = gridRef.value;if ($grid) {$grid.openExport();}
};
</script>

复制到 excel(企业版)

在这里插入图片描述

<template><div><vxe-grid v-bind="gridOptions"></vxe-grid></div>
</template><script setup>
import { reactive } from 'vue'const gridOptions = reactive({border: true,height: 500,showOverflow: true,mouseConfig: {area: true // 是否开启区域选取},keyboardConfig: {isClip: true,isArrow: true,isShift: true,isTab: true,isEnter: true,isFNR: true // 是否开启查找与替换},columns: [{ type: 'seq', width: 60 },{ field: 'name', title: '名字' },{ field: 'num1', title: '货币类型', align: 'right', cellRender: { name: 'FormatNumberInput', props: { type: 'amount', align: 'right' } } },{ field: 'num2', title: '货币类型(带货币符号)', align: 'right', cellRender: { name: 'FormatNumberInput', props: { type: 'amount', align: 'right', showCurrency: true } } },{ field: 'num3', title: '货币类型(负数自动标红)', align: 'right', cellRender: { name: 'FormatNumberInput', showNegativeStatus: true, props: { type: 'amount', align: 'right', showCurrency: true } } }],data: [{ id: 10001, name: '张三', code1: '0002365', code2: '0002365', num1: -3.56, num2: -3.56, num3: -3.56, num4: -3.56, str1: '10,000,000.00', str2: '10,000,000.00' },{ id: 10002, name: '李四', code1: '0002465', code2: '0002465', num1: 1, num2: 1, num3: 1, num4: 1, str1: '90,000,000.00', str2: '90,000,000.00' },{ id: 10003, name: '老六', code1: '0002567', code2: '0002567', num1: 1235640, num2: 1235640, num3: 1235640, num4: 1235640, str1: '100,000', str2: '100,000' },{ id: 10004, name: '小李', code1: '0678865', code2: '0678865', num1: -96300000.4, num2: -96300000.4, num3: -96300000.4, num4: -96300000.4, str1: '', str2: '' },{ id: 10005, name: '老万', code1: '23470565', code2: '23470565', num1: 240.63, num2: 240.63, num3: 240.63, num4: 240.63, str1: '', str2: '' },{ id: 10006, name: '小刘', code1: '086222135', code2: '086222135', num1: 0.1, num2: 0.1, num3: 0.1, num4: 0.1, str1: '', str2: '' },{ id: 10007, name: '老徐', code1: '3600665', code2: '3600665', num1: 0, num2: 0, num3: 0, num4: 0, str1: '330.02', str2: '330.02' },{ id: 10008, name: '老二', code1: '009635', code2: '009635', num1: null, num2: null, num3: null, num4: null, str1: '10,000,000.33', str2: '10,000,000.33' },{ id: 10009, name: '小牛', code1: '09034523', code2: '09034523', num1: 100000000, num2: 100000000, num3: 100000000, num4: 100000000, str1: '', str2: '' },{ id: 10010, name: '小帅', code1: '872220222', code2: '872220222', num1: null, num2: null, num3: null, num4: null, str1: '1,230.30', str2: '1,230.30' },{ id: 10011, name: '老魏', code1: '10022354', code2: '10022354', num1: 96342, num2: 96342, num3: 96342, num4: 96342, str1: '', str2: '' },{ id: 10012, name: '小徐', code1: '0009785', code2: '0009785', num1: -740000, num2: -740000, num3: -740000, num4: -740000, str1: '', str2: '' }]
})
</script>

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

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/pingmian/77194.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

知识图谱 数据准备

任何类型的数据格式都可以用于构建知识图谱&#xff0c;只要能够从中提取出实体&#xff08;Entities&#xff09;、关系&#xff08;Relationships&#xff09;和属性&#xff08;Attributes&#xff09;。但实际操作中&#xff0c;不同数据格式的处理难度、工具支持和效率差异…

Docker 设置镜像源后仍无法拉取镜像问题排查

#记录工作 Windows系统 在使用 Docker 的过程中&#xff0c;许多用户会碰到设置了国内镜像源后&#xff0c;依旧无法拉取镜像的情况。接下来&#xff0c;记录了操作要点以及问题排查方法&#xff0c;帮助我们顺利解决这类问题。 Microsoft Windows [Version 10.0.27823.1000…

如何对Flutter应用程序进行单元测试

Flutter单元测试完全指南&#xff1a;从基础到高级实践 面试求职资源 面试试题小程序&#xff1a;涵盖测试基础、Linux操作系统、MySQL数据库、Web功能测试、接口测试、APPium移动端测试、Python知识、Selenium自动化测试相关、性能测试、计算机网络知识、Jmeter、HR面试等内…

go中我遇到的问题总结

go问题总结 1 - go中的nil等于java中的null吗 在 Go 和 Java 中,nil 和 null 都用于表示“空值”,但它们的实现和使用方式有所不同。 以下是 Go 中的 nil 和 Java 中的 null 之间的对比: 1. Go 中的 nil 在 Go 中,nil 是一个预定义的常量,表示零值。它的行为根据数据类…

【android telecom 框架分析 01】【基本介绍 2】【BluetoothPhoneService为何没有源码实现】

1. 背景 我们会在很多资料上看到 BluetoothPhoneService 类&#xff0c;但是我们在实际 aosp 中确找不到具体的实现&#xff0c; 这是为何&#xff1f; 这是一个很好的问题&#xff01;虽然在车载蓝牙电话场景中我们经常提到类似 BluetoothPhoneService 的概念&#xff0c;但…

微机控制电液伺服汽车减震器动态试验系统

微机控制电液伺服汽车减震器动态试验系统&#xff0c;用于对汽车筒式减震器、减震器台架、驾驶室减震装置、发动机悬置软垫总成、发动机前置楔形支撑总成等的示功图试验、速度特性试验。 主要的技术参数&#xff1a; 1、最大试验力&#xff1a;5kN&#xff1b; 2、试验力测量精…

STM32+dht11+rc522+jq8400的简单使用

1.dht11的使用 硬件&#xff1a;3v3&#xff0c;gnd&#xff0c;data数据线接一个gpio&#xff0c;三根线即可 软件&#xff1a; ①dht11.c #include "dht11.h" #include "delay.h" #include "stdbool.h"static STRUCT_DHT11_TYPEDEF dht11;…

AOSP的Doze模式-DeepIdle 初识

前言 从Android 6.0开始&#xff0c;谷歌引入了Doze模式(打盹模式)的省电技术延长电池使用时间。如果用户长时间未使用设备&#xff0c;低电耗模式会延迟应用后台 CPU 和网络活动&#xff0c;从而延长电池续航时间。根据第三方测试显示&#xff0c;两台同样的Nexus 5&#xff…

用Python Pandas高效操作数据库:从查询到写入的完整指南

一、环境准备与数据库连接 1.1 安装依赖库 pip install pandas sqlalchemy psycopg2 # PostgreSQL # 或 pip install pandas sqlalchemy pymysql # MySQL # 或 pip install pandas sqlalchemy # SQLite 1.2 创建数据库引擎 通过SQLAlchemy创建统一接口&#xff1a…

每日一题(小白)暴力娱乐篇31

首先分析一下题意&#xff0c;需要求出2024的因子&#xff0c;因为我们要求与2024互质的数字&#xff0c;为什么呢&#xff1f;因为我们要求互质说直白点就是我和你两个人没有中间人&#xff0c;我们是自然而然认识的&#xff0c;那我们怎么认识呢&#xff0c;就是直接见面对吧…

电控---printf重定向输出

在嵌入式系统开发中&#xff0c;printf 重定向输出是将标准输出&#xff08;stdout&#xff09;从默认设备&#xff08;如主机终端&#xff09;重新映射到嵌入式设备的特定硬件接口&#xff08;如串口、LCD、USB等&#xff09;的过程。 一、核心原理&#xff1a;标准IO库的底层…

快速认识:数据库、数仓(数据仓库)、数据湖与数据运河

数据技术核心概念对比表 概念核心定义核心功能数据特征典型技术/工具核心应用场景数据库结构化数据的「电子档案柜」&#xff0c;按固定 schema 存储和管理数据&#xff0c;支持高效读写和事务处理。实时事务处理&#xff08;增删改查&#xff09;&#xff0c;确保数据一致性&…

【17】数据结构之图的遍历篇章

目录标题 图的遍历深度优先遍历 Depth First Search广度优先遍历 Breadth First Search 图的遍历 从图中某一个顶点出发&#xff0c;沿着一些边访遍图中所有的顶点&#xff0c;且使用每个顶点仅被访问一次&#xff0c;这个过程称为图的遍历.Graph Traversal. 其中&#xff0c…

简单接口工具(ApiCraft-Web)

ApiCraft-Web 项目介绍 ApiCraft-Web 是一个轻量级的 API 测试工具&#xff0c;提供了简洁直观的界面&#xff0c;帮助开发者快速测试和调试 HTTP 接口。 功能特点 支持多种 HTTP 请求方法&#xff08;GET、POST、PUT、DELETE&#xff09;可配置请求参数&#xff08;Query …

Git进阶操作

Git高阶操作完全指南&#xff1a;解锁专业开发工作流 前言 在当今的软件开发领域&#xff0c;掌握高级Git技能已成为区分普通开发者与专业开发者的关键因素。根据最新的GitHub数据&#xff0c;熟练应用交互式暂存和Rebase等高级功能的开发者&#xff0c;其代码审查通过率平均提…

Python结合AI生成图像艺术作品代码及介绍

为实现生成图像艺术作品&#xff0c;我选用 Stable Diffusion 库结合 Python 编写代码。下面先展示代码&#xff0c;再详细介绍其原理、模块及使用方法等内容。 生成图片代码 import torch from diffusers import StableDiffusionPipeline# 加载预训练模型 pipe StableDiffu…

Linux操作系统--静态库和动态库的生成and四种解决加载找不到动态库的四种方法

目录 必要的知识储备&#xff1a; 生成静态库&#xff1a; 生成动态库&#xff1a; 解决加载找不到动态库的四种方法&#xff1a; 第一种&#xff1a;拷贝到系统默认的库路径 /usr/lib64/ 第二种&#xff1a;在系统默认的库路径/usr/lib64/下建立软链接 第三种&#xff1…

LLM中的N-Gram、TF-IDF和Word embedding

文章目录 1. N-Gram和TF-IDF&#xff1a;通俗易懂的解析1.1 N-Gram&#xff1a;让AI学会"猜词"的技术1.1.1 基本概念1.1.2 工作原理1.1.3 常见类型1.1.4 应用场景1.1.5 优缺点 1.2 TF-IDF&#xff1a;衡量词语重要性的尺子1.2.1 基本概念1.2.2 计算公式1.2.3 为什么需…

Leetcode 3359. 查找最大元素不超过 K 的有序子矩阵【Plus题】

1.题目基本信息 1.1.题目描述 给定一个大小为 m x n 的二维矩阵 grid。同时给定一个 非负整数 k。 返回满足下列条件的 grid 的子矩阵数量&#xff1a; 子矩阵中最大的元素 小于等于 k。 子矩阵的每一行都以 非递增 顺序排序。 矩阵的子矩阵 (x1, y1, x2, y2) 是通过选择…

如何在 Ubuntu 22.04 上安装、配置、使用 Nginx

如何在 Ubuntu 22.04 上安装、配置、使用 Nginx&#xff1f;-阿里云开发者社区 更新应用 sudo apt updatesudo apt upgrade检查必要依赖并安装 sudo apt install -y curl gnupg2 ca-certificates lsb-release安装nginx sudo apt install -y nginx# 启动nginx sudo systemct…