easyExcel 写复杂表头
写模板
模板图片:
实体类(这里没有用@Data 是因为Lombok和easyExcal的版本冲突,在导入读取的时候获取不到值)
package cn.iocoder.yudao.module.project.controller.admin.goods.vo;import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import jdk.nashorn.internal.ir.annotations.Ignore;
import lombok.Data;
import lombok.NoArgsConstructor;import java.math.BigDecimal;
import java.util.List;
import java.util.Map;/*** 商品下载模板* @author px*/
public class GoodsTemplateExcelVO {@ExcelProperty(index = 0)private String bn;@ExcelProperty(index = 1)private String productName;@ExcelProperty(index = 2)private String brandNameCn;@ExcelProperty(index = 3)private String brandNameEn;@ExcelProperty(index = 4)private String brandLogo;@ExcelProperty(index = 5)private String url;@ExcelProperty(index = 6)private String jingle;@ExcelProperty(index = 7)private String categoryName1;@ExcelProperty(index = 8)private String categoryName2;@ExcelProperty(index = 9)private String categoryName3;@ExcelProperty(index = 10)private String unit;@ExcelProperty(index = 11)private String model;@ExcelProperty(index = 12)private String pakeageSpec;@ExcelProperty(index = 13)private String taxCode;@ExcelProperty(index = 14)private String outputTaxRate;@ExcelProperty(index = 15)private String codeBar;@ExcelProperty(index = 16)private BigDecimal price;@ExcelProperty(index = 17)private BigDecimal actualPrice;@ExcelProperty(index = 18)private String discountRate;@ExcelProperty(index = 19)private String isReturnStr;@ExcelProperty(index = 20)private String onlineStateStr;@ExcelProperty(index = 21)private Integer deliveryTime;@ExcelProperty(index = 22)private Integer arrivalTime;@ExcelProperty(index = 23)private Integer batchNum;@ExcelProperty(index = 24)private String firstAreaName;@ExcelProperty(index = 25)private String secondAreaName;@ExcelProperty(index = 26)private String thirdAreaName;@ExcelProperty(index = 27)private String storageArea;@ExcelProperty(index = 28)private Integer storage;@ExcelProperty(index = 29)private String attrJson;@ExcelProperty(index = 30)private String exceptionList;@ExcelIgnoreprivate String projectName;@ExcelIgnoreprivate Integer queueId;public String getBn() {return bn;}public void setBn(String bn) {this.bn = bn;}public String getProductName() {return productName;}public void setProductName(String productName) {this.productName = productName;}public String getBrandNameCn() {return brandNameCn;}public void setBrandNameCn(String brandNameCn) {this.brandNameCn = brandNameCn;}public String getBrandNameEn() {return brandNameEn;}public void setBrandNameEn(String brandNameEn) {this.brandNameEn = brandNameEn;}public String getBrandLogo() {return brandLogo;}public void setBrandLogo(String brandLogo) {this.brandLogo = brandLogo;}public String getUrl() {return url;}public void setUrl(String url) {this.url = url;}public String getJingle() {return jingle;}public void setJingle(String jingle) {this.jingle = jingle;}public String getCategoryName1() {return categoryName1;}public void setCategoryName1(String categoryName1) {this.categoryName1 = categoryName1;}public String getCategoryName2() {return categoryName2;}public void setCategoryName2(String categoryName2) {this.categoryName2 = categoryName2;}public String getCategoryName3() {return categoryName3;}public void setCategoryName3(String categoryName3) {this.categoryName3 = categoryName3;}public String getUnit() {return unit;}public void setUnit(String unit) {this.unit = unit;}public String getModel() {return model;}public void setModel(String model) {this.model = model;}public String getPakeageSpec() {return pakeageSpec;}public void setPakeageSpec(String pakeageSpec) {this.pakeageSpec = pakeageSpec;}public String getTaxCode() {return taxCode;}public void setTaxCode(String taxCode) {this.taxCode = taxCode;}public String getOutputTaxRate() {return outputTaxRate;}public void setOutputTaxRate(String outputTaxRate) {this.outputTaxRate = outputTaxRate;}public String getCodeBar() {return codeBar;}public void setCodeBar(String codeBar) {this.codeBar = codeBar;}public BigDecimal getPrice() {return price;}public void setPrice(BigDecimal price) {this.price = price;}public BigDecimal getActualPrice() {return actualPrice;}public void setActualPrice(BigDecimal actualPrice) {this.actualPrice = actualPrice;}public String getDiscountRate() {return discountRate;}public void setDiscountRate(String discountRate) {this.discountRate = discountRate;}public String getIsReturnStr() {return isReturnStr;}public void setIsReturnStr(String isReturnStr) {this.isReturnStr = isReturnStr;}public String getOnlineStateStr() {return onlineStateStr;}public void setOnlineStateStr(String onlineStateStr) {this.onlineStateStr = onlineStateStr;}public Integer getDeliveryTime() {return deliveryTime;}public void setDeliveryTime(Integer deliveryTime) {this.deliveryTime = deliveryTime;}public Integer getArrivalTime() {return arrivalTime;}public void setArrivalTime(Integer arrivalTime) {this.arrivalTime = arrivalTime;}public Integer getBatchNum() {return batchNum;}public void setBatchNum(Integer batchNum) {this.batchNum = batchNum;}public String getFirstAreaName() {return firstAreaName;}public void setFirstAreaName(String firstAreaName) {this.firstAreaName = firstAreaName;}public String getSecondAreaName() {return secondAreaName;}public void setSecondAreaName(String secondAreaName) {this.secondAreaName = secondAreaName;}public String getThirdAreaName() {return thirdAreaName;}public void setThirdAreaName(String thirdAreaName) {this.thirdAreaName = thirdAreaName;}public String getStorageArea() {return storageArea;}public void setStorageArea(String storageArea) {this.storageArea = storageArea;}public Integer getStorage() {return storage;}public void setStorage(Integer storage) {this.storage = storage;}public String getAttrJson() {return attrJson;}public void setAttrJson(String attrJson) {this.attrJson = attrJson;}public String getExceptionList() {return exceptionList;}public void setExceptionList(String exceptionList) {this.exceptionList = exceptionList;}public String getProjectName() {return projectName;}public void setProjectName(String projectName) {this.projectName = projectName;}public Integer getQueueId() {return queueId;}public void setQueueId(Integer queueId) {this.queueId = queueId;}public GoodsTemplateExcelVO(){}public GoodsTemplateExcelVO(String bn) {this.bn = bn;this.productName = "测试商品";this.brandNameCn = "品牌";this.brandNameEn = "pingpai";this.brandLogo = "https://img30.360buyimg.com/jgsq-productsoa/jfs/t1…5298/88691/63da0918Fb060cb06/6929f345feb64ed2.jpg";this.url = "https://www.ofs.cn/product-394804.html";this.jingle = "介绍";this.categoryName1 = "工具/工具耗材";this.categoryName2 = "手动工具";this.categoryName3 = "扳手";this.unit = "单位";this.model = "T88110-27";this.pakeageSpec = "1*1*1";this.taxCode = "";this.outputTaxRate = "13%";this.codeBar = "";this.discountRate = "20%";this.isReturnStr = "允许";this.onlineStateStr = "上架";this.deliveryTime = 1;this.arrivalTime = 1;this.batchNum = 2;this.firstAreaName = "全国";this.secondAreaName = "";this.thirdAreaName = "";this.storageArea = "重庆";this.storage = 999;this.attrJson = "保质期:12个月;" +"商品简介:徐福记 卷心酥 105g 香浓奶油味";}
}
public void downloadGoodsTemplateFile(HttpServletResponse response) {response.setContentType("application/vnd.ms-excel");response.setCharacterEncoding("UTF-8");response.setHeader("Content-disposition", "attachment;filename=商品模板.xls");GoodsTemplateExcelVO goodsTemplateExcelVO = new GoodsTemplateExcelVO("123");List<GoodsTemplateExcelVO> goodsTemplateExcelVOList = new ArrayList<>();goodsTemplateExcelVOList.add(goodsTemplateExcelVO);try {// 这里需要设置不关闭流WriteCellStyle headWriteCellStyle = new WriteCellStyle();//设置背景颜色headWriteCellStyle.setFillForegroundColor(IndexedColors.WHITE.getIndex());//内容策略WriteCellStyle contentWriteCellStyle = new WriteCellStyle();//设置 水平居中contentWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER);HorizontalCellStyleStrategy horizontalCellStyleStrategy =new HorizontalCellStyleStrategy(headWriteCellStyle, contentWriteCellStyle);EasyExcel.write(response.getOutputStream()).autoCloseStream(Boolean.FALSE).registerWriteHandler(horizontalCellStyleStrategy).head(mergeGoodsDetailHead()).sheet("商品信息")//获取数据填充.doWrite(goodsTemplateExcelVOList);} catch (Exception e) {}}
自定义头部
private List<List<String>> mergeGoodsDetailHead() {String title = "XXX信息统计报表";List<List<String>> list = new ArrayList<>();String erTitle = "MRO标品SKU 商品名称 品牌中文名称 品牌英文名称 品牌图片链接 商品链接 商品介绍 一级分类名称 二级分类名称 " +"三级分类名称 商品单位 商品型号 包装规格 税收编码 销售税税率 条形码 官网价 协议价 折扣率 允许退换货(允许,不允许) 上下架状态(下架,上架) 预计发货时间(天) " +"预计补货时间(天) 最小起订量 一级供货地址 二级供货地址 三级供货地址 库存所在地 库存 类目属性";Arrays.stream(erTitle.split(" ")).forEach(name -> {List<String> head = new ArrayList<>();head.add(title);head.add(name);list.add(head);});return list;}
相关文章:

easyExcel 写复杂表头
写模板 模板图片: 实体类(这里没有用Data 是因为Lombok和easyExcal的版本冲突,在导入读取的时候获取不到值) package cn.iocoder.yudao.module.project.controller.admin.goods.vo;import com.alibaba.excel.annotation.ExcelI…...
关于线程池的执行流程和拒绝策略
使用线程池的好处为: 降低资源消耗:减少线程的创建和销毁带来的性能开销。 提高响应速度:当任务来时可以直接使用,不用等待线程创建 可管理性: 进行统一的分配,监控,避免大量的线程间因互相抢…...
【李忍考研传】二、约定
因为收学生证用了好些时间,李忍把学生证都交给班长后,就赶忙跑去食堂。远远地,他就看到那个瘦小的身影立在食堂正门前,那是他们约定每天午餐集合的地方。 “你咋这么慢啊……” “害!帮班长收东西耽误了点时间&#…...
2023-2-19 刷题情况
修改两个元素的最小分数 题目描述 给你一个下标从 0 开始的整数数组 nums 。 nums 的 最小 得分是满足 0 < i < j < nums.length 的 |nums[i] - nums[j]| 的最小值。nums的 最大 得分是满足 0 < i < j < nums.length 的 |nums[i] - nums[j]| 的最大值。nu…...
LeetCode笔记:Weekly Contest 333
LeetCode笔记:Weekly Contest 333 1. 题目一 1. 解题思路2. 代码实现 2. 题目二 1. 解题思路2. 代码实现 3. 题目三 1. 解题思路2. 代码实现 4. 题目四 比赛链接:https://leetcode.com/contest/weekly-contest-333 1. 题目一 给出题目一的试题链接如下…...
元数据管理 1
1、关于元数据管理原则说法正确的是 (知识点: 三月份模拟题)A.确保员工了解如何访问和使用元数据。B.制定、实施和审核元数据标准,以简化元数据的集成和使用。C.创建反馈机制,以便数据使用者可以将错误或过时的元数据反馈给元数据管理团队。D.以上都对正…...
统计二进制中比特1的个数
快速统计比特1的数量int CountBitOnes(int32_t n) {int result 0;for(;n;result) {n & n-1;}return result; }原理很简单,n-1会将n中最靠近结尾的1减一,这样n&n-1,n中最靠近结尾的1就变成了0;假设n 0b xxxxxxxx100n - 1…...
第三方实现跑马灯和手写实现跑马灯
目录第三方实现跑马灯手写实现跑马灯手写实现跑马灯【整体代码】自己细心研究一下上述代码第三方实现跑马灯 https://vue3-marquee.vercel.app/guide.html#changes-from-v2https://evodiaaut.github.io/vue-marquee-text-component/ 手写实现跑马灯 CSS部分 <style>.m…...

React Native Cannot run program “node“问题
概述 前几天mac重装系统了,用Android studio重新构建React native项目时,报Cannot run program "node"错误。 电脑系统为macOS 12.6.3 (Monterey),M1 Pro芯片。设备信息如下图所示: 完整错误信息如下图所示ÿ…...

python基于vue微信小程序 房屋租赁出租系统
目录 1 绪论 1 1.1课题背景 1 1.2课题研究现状 1 1.3初步设计方法与实施方案 2 1.4本文研究内容 2 2 系统开发环境 4 2.1 2.2MyEclipse环境配置 4 2.3 B/S结构简介 4 2.4MySQL数据库 5 2. 3 系统分析 6 3.1系统可行性分析 6 3.1.1经济可行性 6 3.1.2技术可行性 6 3.1.3运行可行…...
ThreadPoolExecutor管理异步线程笔记
为什么使用线程池? 线程的创建和销毁都需要不小的系统开销,不加以控制管理容易发生OOM错误。避免线程并发抢占系统资源导致系统阻塞。具备一定的线程管理能力(数量、存活时间,任务管理) new ThreadPoolExecutor(int …...

MotoSimEG-VRC教程:动态输送带创建以及示教编程与仿真运行
目录 任务描述 简易输送带外部设备创建 输送带模型添加与配置 工件安装到输送带 输送带输送工件程序编写与仿真运行 任务描述 在MotoSimEG-VRC中创建1条输送带,并且能够实现将工件从输送带起始点位置处输送到结束点位置处。 简易输送带外部设备创建 在MotoS…...

PyTorch 并行训练 DistributedDataParallel完整代码示例
使用大型数据集训练大型深度神经网络 (DNN) 的问题是深度学习领域的主要挑战。 随着 DNN 和数据集规模的增加,训练这些模型的计算和内存需求也会增加。 这使得在计算资源有限的单台机器上训练这些模型变得困难甚至不可能。 使用大型数据集训练大型 DNN 的一些主要挑…...
Golang实现ttl机制保存内存数据
ttl(time-to-live) 数据存活时间,我们这里指数据在内存中保存一段时间,超过期限则不能被读取到,与Redis的ttl机制类似。本文仅实现ttl部分,不考虑序列化和反序列化。 获取当前时间 涉及时间计算,这里首先介绍如何获取…...

js中数字运算结果与预期不一致的问题和解决方案
本文主要是和大家聊聊关于js中经常出现数字运算结果与预期结果不一致的问题,与及解决该问题的的方案。 一、问题现象 如:0.1 0.2的预期结果是0.3,但是在js中得到的计算结果却是0.30000000000000004,如下图所示 如:0…...
C++ Primer Plus 学习笔记(一)——基本类型
字节与字符 计算机内存的基本单位是位(bit),字节(byte)通常指的是8位的内存单元,从这个意义上来说,字节指的就是描述计算机内存量的度量单位。 C对字节的定义则有些不同,C字节由至…...

ChatGpt与Google 谁能给出最好的回答
ChatGPT由于其先进的会话和技术功能而越来越受欢迎。你可以问聊天机器人任何你想问的问题,它会在几秒钟内输出答案。虽然它不是一个搜索引擎,你应该使用ChatGPT作为你的信息来源而不是谷歌,百度吗? 我们来根据国外的一场测试来看一下 ChatG…...

【Redis】一、CentOS64 安装 Redis
1.下载redis https://download.redis.io/releases/2.将 redis 安装包拷贝到 /opt/ 目录 最好自己创建一个文件夹 3.解压 tar -zvxf redis-6.2.1.tar.gz4. 安装gcc yum install gcc5. 进入目录 cd /opt/redis/redis-6.2.1/6. 编译 make7.执行 make install 进行安装 8. …...

Redis底层原理(持久化+分布式锁)
Redis底层原理 持久化 Redis虽然是个内存数据库,但是Redis支持RDB和AOF (Redis Database Backup file(Redis数据备份文件),也被叫做Redis数据快照。简单来说就是把内存中的所有数据都记录到磁盘中 ;Appen…...

Spring Cloud Nacos实战(八) - Nacos集群配置
Nacos集群配置 更改Nacos启动命令配置原理 我们现在知道,想要启动Naocs只需要启动startup.sh命令即可,但是如果启动3个Nacos那?所以如果我们需要启动多个Nacos,其实Nacos本身默认启动就是集群模式。 注意点:如果是l…...

《通信之道——从微积分到 5G》读书总结
第1章 绪 论 1.1 这是一本什么样的书 通信技术,说到底就是数学。 那些最基础、最本质的部分。 1.2 什么是通信 通信 发送方 接收方 承载信息的信号 解调出其中承载的信息 信息在发送方那里被加工成信号(调制) 把信息从信号中抽取出来&am…...

c#开发AI模型对话
AI模型 前面已经介绍了一般AI模型本地部署,直接调用现成的模型数据。这里主要讲述讲接口集成到我们自己的程序中使用方式。 微软提供了ML.NET来开发和使用AI模型,但是目前国内可能使用不多,至少实践例子很少看见。开发训练模型就不介绍了&am…...

python执行测试用例,allure报乱码且未成功生成报告
allure执行测试用例时显示乱码:‘allure’ �����ڲ����ⲿ���Ҳ���ǿ�&am…...

云原生玩法三问:构建自定义开发环境
云原生玩法三问:构建自定义开发环境 引言 临时运维一个古董项目,无文档,无环境,无交接人,俗称三无。 运行设备的环境老,本地环境版本高,ssh不过去。正好最近对 腾讯出品的云原生 cnb 感兴趣&…...
Linux离线(zip方式)安装docker
目录 基础信息操作系统信息docker信息 安装实例安装步骤示例 遇到的问题问题1:修改默认工作路径启动失败问题2 找不到对应组 基础信息 操作系统信息 OS版本:CentOS 7 64位 内核版本:3.10.0 相关命令: uname -rcat /etc/os-rele…...
《C++ 模板》
目录 函数模板 类模板 非类型模板参数 模板特化 函数模板特化 类模板的特化 模板,就像一个模具,里面可以将不同类型的材料做成一个形状,其分为函数模板和类模板。 函数模板 函数模板可以简化函数重载的代码。格式:templa…...

MySQL 知识小结(一)
一、my.cnf配置详解 我们知道安装MySQL有两种方式来安装咱们的MySQL数据库,分别是二进制安装编译数据库或者使用三方yum来进行安装,第三方yum的安装相对于二进制压缩包的安装更快捷,但是文件存放起来数据比较冗余,用二进制能够更好管理咱们M…...

深度学习水论文:mamba+图像增强
🧀当前视觉领域对高效长序列建模需求激增,对Mamba图像增强这方向的研究自然也逐渐火热。原因在于其高效长程建模,以及动态计算优势,在图像质量提升和细节恢复方面有难以替代的作用。 🧀因此短时间内,就有不…...
【LeetCode】3309. 连接二进制表示可形成的最大数值(递归|回溯|位运算)
LeetCode 3309. 连接二进制表示可形成的最大数值(中等) 题目描述解题思路Java代码 题目描述 题目链接:LeetCode 3309. 连接二进制表示可形成的最大数值(中等) 给你一个长度为 3 的整数数组 nums。 现以某种顺序 连接…...
人工智能 - 在Dify、Coze、n8n、FastGPT和RAGFlow之间做出技术选型
在Dify、Coze、n8n、FastGPT和RAGFlow之间做出技术选型。这些平台各有侧重,适用场景差异显著。下面我将从核心功能定位、典型应用场景、真实体验痛点、选型决策关键点进行拆解,并提供具体场景下的推荐方案。 一、核心功能定位速览 平台核心定位技术栈亮…...