
easyexcel-write
基于 Alibaba EasyExcel(com.alibaba:easyexcel:4.0.3)的 Excel 数据写入技能。覆盖最简写入(3 种写法)、复杂表头(多级)、@ExcelProperty/@ExcelIgnore/@DateTimeFormat/@NumberFormat 注解、includeColumn/excludeColumn 选择列、@ColumnWidth/@ContentRowHeight 样式注解、@HeadStyle/@ContentStyle 自定义样式、合并单元格(@ContentLoopMerge/LoopMergeStrategy)、图片导出(File/InputStream/URL/byte[])、超链接/批注/公式/富文本(WriteCellData)、动态表头、自动列宽、自定义拦截器(CellWriteHandler/SheetWriteHandler/RowWriteHandler)、分页分批写入、Web 下载直接写 OutputStream、03/07 版兼容。当用户需要程序化生成 Excel(无预制模板)导出订单/用户/财务/库存/报表/对账单/审批单等结构化数据时使用此技能,不适用于按预制模板填充(改用 easyexcel-fill)、不适用于读取 Excel(改用 easyexcel-read)。
- Installs
- 72
- Last 24h
- —
- Trending rank
- —
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/full-stack-skills/java-skills --skill easyexcel-write- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads easyexcel-write automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
EasyExcel 数据写入(Write)
官方文档:https://easyexcel.opensource.alibaba.com/docs/current/quickstart/write 官方示例:https://github.com/alibaba/easyexcel/blob/master/easyexcel-test/src/test/java/com/alibaba/easyexcel/test/demo/write/WriteTest.java 当前版本:
com.alibaba:easyexcel:4.0.3(Apache-2.0,仓库已归档,仅做 Bug 修复)
本技能专注于 "程序化生成 Excel" 场景。当用户没有预制模板、要求用 Java 对象/Map 直接生成结构化 Excel(订单、用户、财务、库存、报表、对账单、审批单)时,应当使用本技能。
Capability Boundaries
✅ 强项
- 最简写入(JDK8+ 写法、传统写法、Builder 写法)
- 复杂表头(多级表头
@ExcelProperty({"主标题", "副标题"})) - 选择性导出列(
includeColumnFiledNames/excludeColumnFiledNames) - 注解定义格式(
@ColumnWidth@ContentRowHeight@DateTimeFormat@NumberFormat) - 自定义样式(注解方式 / 拦截器方式 /
HorizontalCellStyleStrategy) - 合并单元格(
@ContentLoopMerge/LoopMergeStrategy) - 图片导出(File/InputStream/URL/byte[] 多种来源)
- 超链接/批注/公式/富文本(
WriteCellData体系) - 动态表头(运行时决定表头)
- 多次写入/多 Sheet/多 Table
- Web 直接输出到
HttpServletResponse
⚠️ 限制
- 单 Sheet 建议 < 5000 行一次性写入(数据量大用分批)
- 样式对象最多创建 6W 个,否则 Excel 打不开
- 图片会驻内存,超大图建议上传到 OSS
- 批注需要
inMemory(true) - 03 版(
.xls)兼容性需用excelType(ExcelTypeEnum.XLS)
❌ Out of Scope(不该用本技能的场景,请改用其它技能)
- 按预制模板填充 → 不适用本技能,使用
easyexcel-fill - 读取 Excel 数据 → 不适用本技能,使用
easyexcel-read - CSV 文件处理 → 不适用本技能,自行使用 commons-csv / OpenCSV
- Word/PPT → 不适用本技能,使用 Apache POI / Apache POI-XML
Data Privacy
本技能不收集、存储或传输任何用户数据。所有代码示例仅用于本地开发参考。
When to use this skill
- 用户说"导出 Excel"、"生成 Excel"、"下载 Excel"、"导出订单/用户/财务/库存"
- 没有预制模板,需要程序化生成结构化 Excel
- 业务上有"分 Sheet(按月份/状态/类型)"、"分 Table(多个表块)"等需求
- 需要导出图片、超链接、公式、富文本、合并单元格
Quick Start
典型调用方式(3 种写法):
// 写法 1:JDK8+ 用 Supplier(since 3.0.0-beta1,最简洁)
EasyExcel.write(fileName, DemoData.class)
.sheet("模板")
.doWrite(() -> data());
// 写法 2:传统 + 已有 List
List<DemoData> data = data();
EasyExcel.write(fileName, DemoData.class)
.sheet("模板")
.doWrite(data);
// 写法 3:Builder(多次写入 / 复杂配置)
try (ExcelWriter excelWriter = EasyExcel.write(fileName, DemoData.class).build()) {
WriteSheet writeSheet = EasyExcel.writerSheet("模板").build();
excelWriter.write(data(), writeSheet);
}
官方原文:"数据量建议 5000 以内"(单 sheet 一次性写入推荐上限)。
Workflow
Step 1. 定义数据模型 — 编写 DTO/VO,标注 @ExcelProperty 等注解
Step 2. 选择写入方式 — 单次 doWrite() / 多次 excelWriter.write() / 多次 doWrite() 循环
Step 3. 配置 Builder — 包含列选择、表头、样式、注册拦截器等
Step 4. 构造数据 — 准备 List<DTO> / List<List<String>>
Step 5. 执行写入 — try-with-resources 关闭 ExcelWriter
Step 6. 验证输出 — 打开生成的 .xlsx 检查表头/样式/格式/合并
Critical: 注解速查
| 注解 | 用途 | 关键属性 |
|---|---|---|
@ExcelProperty | 指定列名/索引/转换器 | value, index, order, converter |
@ExcelIgnore | 忽略该字段 | —— |
@ExcelIgnoreUnannotated | 类级:未标注字段不参与读写 | —— |
@DateTimeFormat | 日期格式 | value, use1904windowing |
@NumberFormat | 数字格式 | value, roundingMode |
@ColumnWidth | 列宽 | value |
@HeadRowHeight | 表头行高 | value |
@ContentRowHeight | 内容行高 | value |
@HeadStyle | 表头样式(POI 风格) | fillPatternType, fillForegroundColor, font 等 |
@HeadFontStyle | 表头字体 | fontHeightInPoints, color, bold 等 |
@ContentStyle | 内容样式 | 同 HeadStyle |
@ContentFontStyle | 内容字体 | 同 HeadFontStyle |
@ContentLoopMerge | 循环合并 | eachRow |
@OnceAbsoluteMerge | 一次性绝对合并 | firstRowIndex lastRowIndex 等 |
官方原文:
order默认Integer.MAX_VALUE;优先级:index>order>value。 官方原文:"不建议 index 和 name 同时用,要么只用index,要么只用name匹配"
Reference Library(按需加载)
详细代码与注释已拆分到 references/。按场景加载:
API & 基础模式
- references/api/3-write-modes.md — 3 种基础写入模式(最简 / 选择列 / 多次写入)
- references/api/key-classes.md — Key Classes / Methods 速查
模式化(表头 / 样式 / 合并 / 图片 / 富文本 / Web / 高级 / 大数据)
- references/patterns/header-format-style.md — 复杂表头 / 自定义样式(注解 + 拦截器)
- references/scenarios/merge-cell.md — 合并单元格
- references/scenarios/image-export.md — 图片导出(多来源 + 多图嵌入)
- references/scenarios/hyperlink-comment-formula-richtext.md — 超链接 / 批注 / 公式 / 富文本
- references/scenarios/web-download.md — Web 下载(含失败回 JSON)
- references/scenarios/advanced.md — 动态表头 / 自动列宽 / 自定义拦截器 / 03 版兼容
- references/scenarios/million-row.md — 百万级分批写入
故障排查
- references/troubleshooting/gotchas.md — 12 条常见错误与正确做法
References
- 官方文档:https://easyexcel.opensource.alibaba.com/docs/current/quickstart/write
- 官方示例:https://github.com/alibaba/easyexcel/blob/master/easyexcel-test/src/test/java/com/alibaba/easyexcel/test/demo/write/WriteTest.java
- 项目主页:https://easyexcel.opensource.alibaba.com/
- GitHub:https://github.com/alibaba/easyexcel
- API 参考:https://easyexcel.opensource.alibaba.com/docs/current/api/
FAQ
What does the easyexcel-write skill do?
基于 Alibaba EasyExcel(com.alibaba:easyexcel:4.0.3)的 Excel 数据写入技能。覆盖最简写入(3 种写法)、复杂表头(多级)、@ExcelProperty/@ExcelIgnore/@DateTimeFormat/@NumberFormat 注解、includeColumn/excludeColumn 选择列、@ColumnWidth/@ContentRowHeight 样式注解、@HeadStyle/@ContentStyle 自定义样式、合并单元格(@ContentLoopMerge/LoopMergeStrategy)、图片导出(File/InputStream/URL/byte[])、超链接/批注/公式/富文本(WriteCellData)、动态表头、自动列宽、自定义拦截器(CellWriteHandler/SheetWriteHandler/RowWriteHandler)、分页分批写入、Web 下载直接写 OutputStream、03/07 版兼容。当用户需要程序化生成 Excel(无预制模板)导出订单/用户/财务/库存/报表/对账单/审批单等结构化数据时使用此技能,不适用于按预制模板填充(改用 easyexcel-fill)、不适用于读取 Excel(改用 easyexcel-read)。
How do I install easyexcel-write?
Run npx skills add https://github.com/full-stack-skills/java-skills --skill easyexcel-write in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/easyexcel-write/ (personal) or .claude/skills/easyexcel-write/ (project).
Which AI agents can use easyexcel-write?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is easyexcel-write safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains easyexcel-write?
It is published by full-stack-skills in full-stack-skills/java-skills. It has 72 recorded installs.
More from full-stack-skills/java-skills
java-development-manual
full-stack-skills/java-skills
Java开发手册规约集合,基于阿里巴巴Java开发手册(嵩山版)。 涵盖7大维度:编程规约、异常日志、单元测试、安全规约、MySQL数据库、工程结构、设计规约。 当用户需要:(1) 编写或审查Java代码 (2) 检查命名/代码规范 (3) 处理异常和日志 (4) 编写单元测试 (5) 安全编码 (6) 数据库设计 (7) 工程架构设计时使用此skill。 触发词:Java规范、阿里规约、代码规范、开发手册、编程规约、异常处理、单元测试、安全、MySQL、工程结构、设计模式。
mybatis-plus-patterns
full-stack-skills/java-skills
Open the skill to read its SKILL.md instructions.
java-code-comments
full-stack-skills/java-skills
Provides comprehensive guidance for adding Java code comments following industry standards and best practices. This skill helps add class-level comments, method-level comments, and field-level comments to Java code. Use when the user wants to add comments to Java code, needs to document Java classes/methods/fields, wants to improve code documentation, or needs to generate JavaDoc comments. This skill covers Controller, Service, ServiceImpl, Mapper, Model, Entity, BO (Business Object), DTO, VO, and other common Java component types. The skill follows a systematic workflow: scan codebase, identify components, create todo list, and add comments in order (class comments → method comments → field comments).
java-conventions
full-stack-skills/java-skills
统一 Java 项目编码规范与注释规范(SLF4J+Lombok 日志、Bean Lombok 注解选择、判空 Objects/Optional、工具类优先级 Spring→Apache Commons→Hutool→Guava、复杂逻辑用设计模式/简单逻辑不拆分、Controller/Service/ServiceImpl/Mapper 注释一致性)。当需要“按 Java 规范重构/Review/补全注释/统一日志/统一工具类使用/补全 JavaDoc”时使用。
mybatis-patterns
full-stack-skills/java-skills
Open the skill to read its SKILL.md instructions.
mapstruct-patterns
full-stack-skills/java-skills
MapStruct 最佳实践模式。从官方 Reference Guide 提炼,覆盖 Mapper 三种定义方式(接口/抽象类/default方法)、Spring 注入策略(CONSTRUCTOR推荐/SETTER解决循环依赖)、嵌套映射模式(显式子方法 dot notation 一次性配置)、@Qualifier @Named 的安全选择、Lombok 集成规则、@MappingComposition 谨慎使用。 纠正 LLM 最常见的错误:用反射 BeanUtils 而非编译期 MapStruct、嵌套映射全写在一个方法、不知 SETTER 解决循环依赖。
Popular data & databases skills
supabase-postgres-best-practices
supabase/agent-skills
Postgres best practices maintained by Supabase, for Postgres running anywhere. Load this skill BEFORE writing or changing anything that lives in a Postgres database: creating or altering tables and columns (including choosing column types), schema design, migrations and declarative schema files, RLS policies and the tests that verify them, indexes, triggers, database functions, queues and scheduled jobs (pgcron, pgmq), vector/semantic search (pgvector), and restoring dumps (pgrestore) or importing data. Also load it when diagnosing slow queries, high CPU, timeouts, EXPLAIN plans, connection exhaustion, locking, bloat, or rows visible to the wrong user or tenant. This is not just a performance guide — schema, migration, security, and SQL authoring tasks need these rules too, even for a one-column change or a single query.
prisma-client-api
prisma/skills
Prisma Client API reference covering model queries, filters, operators, and client methods. Use when writing database queries, using CRUD operations, filtering data, or configuring Prisma Client. Triggers on "prisma query", "findMany", "create", "update", "delete", "$transaction".
prisma-database-setup
prisma/skills
Deprecated compatibility name for prisma-orm-setup. Use only when a user or existing integration explicitly invokes prisma-database-setup; otherwise select prisma-orm-setup.
prisma-cli
prisma/skills
Prisma ORM 7 CLI reference for existing Prisma 7 applications or explicitly selected Prisma 7 workflows. Covers prisma init, generate, migrate, db, dev, studio, and mcp. For setup, connection repair, or Prisma 8, use prisma-orm-setup; not the Prisma Platform CLI.
prisma-postgres
prisma/skills
Deprecated compatibility name for prisma-postgres-setup. Use only when a user or existing integration explicitly invokes prisma-postgres; otherwise select prisma-postgres-setup.
prisma-driver-adapter-implementation
prisma/skills
Required reference for Prisma ORM 7 SQL driver adapter work. Use when implementing or modifying adapters, adding database drivers, or touching SqlDriverAdapter, Transaction, savepoint, result mapping, or DriverAdapterError behavior. Covers current transaction lifecycle, optional savepoint hooks, original database-error preservation, and verification.