惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
V
Visual Studio Blog
P
Privacy International News Feed
月光博客
月光博客
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
L
Lohrmann on Cybersecurity
N
News and Events Feed by Topic
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Apple Machine Learning Research
Apple Machine Learning Research
阮一峰的网络日志
阮一峰的网络日志
Webroot Blog
Webroot Blog
T
Threatpost
宝玉的分享
宝玉的分享
The Last Watchdog
The Last Watchdog
小众软件
小众软件
L
LINUX DO - 最新话题
C
Cisco Blogs
T
Troy Hunt's Blog
Schneier on Security
Schneier on Security
酷 壳 – CoolShell
酷 壳 – CoolShell
www.infosecurity-magazine.com
www.infosecurity-magazine.com
雷峰网
雷峰网
G
GRAHAM CLULEY
有赞技术团队
有赞技术团队
Know Your Adversary
Know Your Adversary
博客园 - 叶小钗
罗磊的独立博客
V
V2EX
博客园 - Franky
P
Proofpoint News Feed
SecWiki News
SecWiki News
腾讯CDC
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Jina AI
Jina AI
博客园 - 三生石上(FineUI控件)
S
Secure Thoughts
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Google DeepMind News
Google DeepMind News
Attack and Defense Labs
Attack and Defense Labs
人人都是产品经理
人人都是产品经理
The Cloudflare Blog
PCI Perspectives
PCI Perspectives
V2EX - 技术
V2EX - 技术
Google DeepMind News
Google DeepMind News
Last Week in AI
Last Week in AI
aimingoo的专栏
aimingoo的专栏
Cisco Talos Blog
Cisco Talos Blog
N
News and Events Feed by Topic
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
S
SegmentFault 最新的问题

博客园 - npe0

策略模式在项目中的应用 博文阅读密码验证 - 博客园 MyBatis-Plus 的动态SQL片段用法 docker镜像搬运命令 macbook绕过安全控制安装第三方软件 Python中使用列表、map和filter函数配合lambda表达式来操作集合 阿里通义千问大模型初探 java.io.IOException: Cannot run program “az”: CreateProcess error=2, 系统找不到指定的文件。 Git使用问题记录 seata的分布式事务处理机制 JVM常用命令 你可能不知道的Collectors用法 easyexcel导出Bigdecimal数据格式问题 百万千万级Excel导出 arthas 常用命令 对find,xargs,grep和管道的一些深入理解 PlantUML 分库分表 jvm优化
EasyExcel的多级表头
npe0 · 2025-12-12 · via 博客园 - npe0

列优先结构:List<List> 中:
外层 List 的每个元素代表一列,如果每一列的第一行值相同,就会合并列
内层 List 代表该列的多级表头(从最上级到最下级),也就是行,如果每一行的值相同,就会合并行
如果表头是空白,可以使用空格代替,或者多个空格,代替实际值,防止其合并,显示出来跟空值一样
`
public class HeaderStructureExample {

/**
* 演示三列的表头结构
* 期望的Excel效果:
* ┌───────────┬─────────────┐
* │ 基本信息 │ 联系方式 │
* ├─────┬─────┼──────┬──────┤
* │ 姓名 │ 年龄│ 手机 │ 邮箱 │
* └─────┴─────┴──────┴──────┘
*/
public static List<List> createThreeColumnHeader() {
List<List> head = new ArrayList<>();

// 第1列:基本信息 -> 姓名
head.add(Arrays.asList("基本信息", "姓名"));

// 第2列:基本信息 -> 年龄
head.add(Arrays.asList("基本信息", "年龄"));

// 第3列:联系方式 -> 手机
head.add(Arrays.asList("联系方式", "手机"));

// 第4列:联系方式 -> 邮箱
head.add(Arrays.asList("联系方式", "邮箱"));

return head;
}

/**
* 对应的合并区域
*/
public static List<int[]> createThreeColumnMergeRegions() {
List<int[]> mergeRegions = new ArrayList<>();
// 合并第0行的第0-1列(基本信息)
mergeRegions.add(new int[]{0, 0, 0, 1});
// 合并第0行的第2-3列(联系方式)
mergeRegions.add(new int[]{0, 0, 2, 3});
return mergeRegions;
}
}

`