# AnyExcel **Repository Path**: zhouchuang/AnyExcel ## Basic Information - **Project Name**: AnyExcel - **Description**: 简单易用强大的excel工具类 随意配置行高,字体样式,列宽,背景颜色 自动合并单元格,设置好跨单元格字段后,会自动合并跨单元格内容 对表格内容进行处理,比如身份证脱敏处理 对表格内容根据业务需求动态设置字体样式,比如高亮显示不及格学生的成绩 支持Excel文件输出到本地和输出到浏览器 - **Primary Language**: Java - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2023-07-11 - **Last Updated**: 2025-03-13 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # AnyExcel #### 介绍 AnyExcel用于Excel生成工具。它可以帮助程序员快速、准确地创建Excel报表,提高工作效率。 AnyExcel通常具有以下特点和功能: 随意配置行高,字体样式,列宽,背景颜色 自动合并单元格,设置好跨单元格字段后,会自动合并跨单元格内容 对表格内容进行处理,比如身份证脱敏处理 对表格内容根据业务需求动态设置字体样式,比如高亮显示不及格学生的成绩 支持Excel文件输出到本地和输出到浏览器 xml,cvs等组件后续扩展 #### 使用说明 1. 设置表头(内容,字体,行高,颜色) ``` @ExcelAssistant(title = "个人信息(姓名,年龄,身份证)", column = @ExcelAssistant.Style(font = @ExcelAssistant.Style.Font(height = (short)20))) ``` 2. 设置列(内容,字体,列宽,颜色) ``` @ExcelAssistant(title = "姓名",column = @ExcelAssistant.Style(width = 2000,color = 14)) ``` 3. 合并单元格(成绩单元格合并) ``` @ExcelAssistant(title = "语文",mergeRelationColumn = "成绩",column = @ExcelAssistant.Style(width = 2000)) public Integer chinese; @ExcelAssistant(title = "数学",mergeRelationColumn = "成绩",column = @ExcelAssistant.Style(width = 2000)) public Integer math; ``` 4. 根据条件修改内容,如加敏 ``` @Override public void update() { if(this.idCard != null){ this.idCard = this.idCard.substring(0,10)+"****"+this.idCard.substring(14,18); } } ``` 5. 根据内容显示不同的样式,比如不及格用灰色表示 ``` @Override @SneakyThrows public IStyle.StyleInfo style(String name, Object value) { IStyle.StyleInfo styleInfo = IStyle.StyleInfo.newEmpty(); if(name.equals("math") || name.equals("chinese")){ Integer math = (Integer)value; if(math<60){ styleInfo.getFont().setColor(IndexedColors.GREY_50_PERCENT.index); } if(math>90){ styleInfo.getFont().setColor(IndexedColors.RED.index); styleInfo.getFont().setBold(true); } } return styleInfo; } ``` #### 输出效果 ![输入图片说明](src/main/resources/anyExcel.png) #### 参与贡献 zhouchuang