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

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 写复杂表头

写模板 模板图片&#xff1a; 实体类&#xff08;这里没有用Data 是因为Lombok和easyExcal的版本冲突&#xff0c;在导入读取的时候获取不到值&#xff09; package cn.iocoder.yudao.module.project.controller.admin.goods.vo;import com.alibaba.excel.annotation.ExcelI…...

关于线程池的执行流程和拒绝策略

使用线程池的好处为&#xff1a; 降低资源消耗&#xff1a;减少线程的创建和销毁带来的性能开销。 提高响应速度&#xff1a;当任务来时可以直接使用&#xff0c;不用等待线程创建 可管理性&#xff1a; 进行统一的分配&#xff0c;监控&#xff0c;避免大量的线程间因互相抢…...

【李忍考研传】二、约定

因为收学生证用了好些时间&#xff0c;李忍把学生证都交给班长后&#xff0c;就赶忙跑去食堂。远远地&#xff0c;他就看到那个瘦小的身影立在食堂正门前&#xff0c;那是他们约定每天午餐集合的地方。 “你咋这么慢啊……” “害&#xff01;帮班长收东西耽误了点时间&#…...

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笔记&#xff1a;Weekly Contest 333 1. 题目一 1. 解题思路2. 代码实现 2. 题目二 1. 解题思路2. 代码实现 3. 题目三 1. 解题思路2. 代码实现 4. 题目四 比赛链接&#xff1a;https://leetcode.com/contest/weekly-contest-333 1. 题目一 给出题目一的试题链接如下…...

元数据管理 1

1、关于元数据管理原则说法正确的是 (知识点: 三月份模拟题)A.确保员工了解如何访问和使用元数据。B.制定、实施和审核元数据标准&#xff0c;以简化元数据的集成和使用。C.创建反馈机制&#xff0c;以便数据使用者可以将错误或过时的元数据反馈给元数据管理团队。D.以上都对正…...

统计二进制中比特1的个数

快速统计比特1的数量int CountBitOnes(int32_t n) {int result 0;for(;n;result) {n & n-1;}return result; }原理很简单&#xff0c;n-1会将n中最靠近结尾的1减一&#xff0c;这样n&n-1&#xff0c;n中最靠近结尾的1就变成了0&#xff1b;假设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重装系统了&#xff0c;用Android studio重新构建React native项目时&#xff0c;报Cannot run program "node"错误。 电脑系统为macOS 12.6.3 (Monterey)&#xff0c;M1 Pro芯片。设备信息如下图所示&#xff1a; 完整错误信息如下图所示&#xff…...

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管理异步线程笔记

为什么使用线程池&#xff1f; 线程的创建和销毁都需要不小的系统开销&#xff0c;不加以控制管理容易发生OOM错误。避免线程并发抢占系统资源导致系统阻塞。具备一定的线程管理能力&#xff08;数量、存活时间&#xff0c;任务管理&#xff09; new ThreadPoolExecutor(int …...

MotoSimEG-VRC教程:动态输送带创建以及示教编程与仿真运行

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

PyTorch 并行训练 DistributedDataParallel完整代码示例

使用大型数据集训练大型深度神经网络 (DNN) 的问题是深度学习领域的主要挑战。 随着 DNN 和数据集规模的增加&#xff0c;训练这些模型的计算和内存需求也会增加。 这使得在计算资源有限的单台机器上训练这些模型变得困难甚至不可能。 使用大型数据集训练大型 DNN 的一些主要挑…...

Golang实现ttl机制保存内存数据

ttl(time-to-live) 数据存活时间&#xff0c;我们这里指数据在内存中保存一段时间&#xff0c;超过期限则不能被读取到&#xff0c;与Redis的ttl机制类似。本文仅实现ttl部分&#xff0c;不考虑序列化和反序列化。 获取当前时间 涉及时间计算&#xff0c;这里首先介绍如何获取…...

js中数字运算结果与预期不一致的问题和解决方案

本文主要是和大家聊聊关于js中经常出现数字运算结果与预期结果不一致的问题&#xff0c;与及解决该问题的的方案。 一、问题现象 如&#xff1a;0.1 0.2的预期结果是0.3&#xff0c;但是在js中得到的计算结果却是0.30000000000000004&#xff0c;如下图所示 如&#xff1a;0…...

C++ Primer Plus 学习笔记(一)——基本类型

字节与字符 计算机内存的基本单位是位&#xff08;bit&#xff09;&#xff0c;字节&#xff08;byte&#xff09;通常指的是8位的内存单元&#xff0c;从这个意义上来说&#xff0c;字节指的就是描述计算机内存量的度量单位。 C对字节的定义则有些不同&#xff0c;C字节由至…...

ChatGpt与Google 谁能给出最好的回答

ChatGPT由于其先进的会话和技术功能而越来越受欢迎。你可以问聊天机器人任何你想问的问题&#xff0c;它会在几秒钟内输出答案。虽然它不是一个搜索引擎&#xff0c;你应该使用ChatGPT作为你的信息来源而不是谷歌&#xff0c;百度吗? 我们来根据国外的一场测试来看一下 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虽然是个内存数据库&#xff0c;但是Redis支持RDB和AOF &#xff08;Redis Database Backup file&#xff08;Redis数据备份文件&#xff09;&#xff0c;也被叫做Redis数据快照。简单来说就是把内存中的所有数据都记录到磁盘中 &#xff1b;Appen…...

Spring Cloud Nacos实战(八) - Nacos集群配置

Nacos集群配置 更改Nacos启动命令配置原理 我们现在知道&#xff0c;想要启动Naocs只需要启动startup.sh命令即可&#xff0c;但是如果启动3个Nacos那&#xff1f;所以如果我们需要启动多个Nacos&#xff0c;其实Nacos本身默认启动就是集群模式。 注意点&#xff1a;如果是l…...

全面掌握AWD-Watchbird:PHP Web应用防火墙实战部署指南

全面掌握AWD-Watchbird&#xff1a;PHP Web应用防火墙实战部署指南 【免费下载链接】awd-watchbird A powerful PHP WAF for AWD 项目地址: https://gitcode.com/gh_mirrors/aw/awd-watchbird 在当今网络安全威胁日益复杂的背景下&#xff0c;Web应用防火墙&#xff08;…...

免费开源的终极分子绘图神器:5分钟快速上手Ketcher完整指南

免费开源的终极分子绘图神器&#xff1a;5分钟快速上手Ketcher完整指南 【免费下载链接】ketcher Web-based molecule sketcher 项目地址: https://gitcode.com/gh_mirrors/ke/ketcher 你是否厌倦了笨重的化学绘图软件&#xff1f;想找一款既专业又轻量的分子结构编辑器…...

为什么顶尖营养实验室都在凌晨2点运行NotebookLM?揭秘膳食-微生物-代谢轴研究中的3大认知跃迁节点

更多请点击&#xff1a; https://intelliparadigm.com 第一章&#xff1a;NotebookLM营养学研究辅助的范式革命 从文献沼泽到知识图谱驱动 传统营养学研究长期受限于海量异构文献&#xff08;临床试验、膳食调查、代谢组学报告&#xff09;的语义割裂与人工综述瓶颈。Noteboo…...

终极指南:如何利用Awesome Public Datasets构建专业级数据科学项目

终极指南&#xff1a;如何利用Awesome Public Datasets构建专业级数据科学项目 【免费下载链接】awesome-public-datasets A topic-centric list of HQ open datasets. 项目地址: https://gitcode.com/GitHub_Trending/aw/awesome-public-datasets 在当今数据驱动的时代…...

魔兽世界宏编辑器终极指南:5分钟掌握GSE高级技能自动化

魔兽世界宏编辑器终极指南&#xff1a;5分钟掌握GSE高级技能自动化 【免费下载链接】GSE-Advanced-Macro-Compiler GSE is an alternative advanced macro editor and engine for World of Warcraft. 项目地址: https://gitcode.com/gh_mirrors/gs/GSE-Advanced-Macro-Compi…...

VR技术如何革新无障碍设计:Empath-D系统实践

1. VR技术赋能无障碍设计的创新实践作为一名长期关注人机交互技术的开发者&#xff0c;我亲历了VR技术从娱乐工具到专业设计辅助的转型过程。Empath-D系统的出现标志着无障碍设计进入了"共情式开发"的新阶段——开发者不再需要凭空想象用户需求&#xff0c;而是能真正…...

AI代码库合规审计完整指南:5步自动化审查流程揭秘

AI代码库合规审计完整指南&#xff1a;5步自动化审查流程揭秘 【免费下载链接】Tutorial-Codebase-Knowledge Pocket Flow: Codebase to Tutorial 项目地址: https://gitcode.com/gh_mirrors/tu/Tutorial-Codebase-Knowledge 在当今快速发展的软件开发环境中&#xff0c…...

基于多模态视觉模型和图文向量模型的工业图像知识库研究与应用

目录1 概述... 12 单一模型分析的局限性... 23 多模态视觉模型和图文向量模型的优势... 34 多模态视觉模型和图文向量模型应用场景... 45 多模态视觉模型和图文向量模型原理... 46 多模态视觉模型和图文向量模型应用... 86.1 图片知识库... 86.2 检索图片... 117.总结... 13…...

ArcGIS Pro脚本工具实战:一键自动化面要素数据质检与修复流程

1. 为什么需要自动化面要素质检工具 做GIS数据处理的朋友们应该都深有体会&#xff0c;每次拿到一批新的面要素数据&#xff0c;最头疼的就是要检查各种几何错误。传统的手动检查方式有多痛苦&#xff1f;我给大家列几个典型场景&#xff1a; 检查重叠要素要用拓扑工具&#xf…...

Go语言算法复杂度分析:时间与空间

Go语言算法复杂度分析&#xff1a;时间与空间 1. 复杂度表示 // O(1) - 常数时间 func getFirstElement(arr []int) int {return arr[0] }// O(n) - 线性时间 func findMax(arr []int) int {max : arr[0]for _, v : range arr {if v > max {max v}}return max }// O(n^2) -…...