导出excel替换

This commit is contained in:
wkc
2026-01-27 17:55:53 +08:00
parent 79cd4fe755
commit 5b0c338b5e
20 changed files with 4261 additions and 1503 deletions

View File

@@ -77,6 +77,12 @@
<artifactId>poi-ooxml</artifactId>
</dependency>
<!-- easyexcel工具 -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
</dependency>
<!-- Token生成与解析-->
<dependency>
<groupId>io.jsonwebtoken</groupId>

View File

@@ -1,17 +1,17 @@
package com.ruoyi.common.annotation;
import com.ruoyi.common.utils.poi.ExcelHandlerAdapter;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.math.BigDecimal;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.IndexedColors;
import com.ruoyi.common.utils.poi.ExcelHandlerAdapter;
/**
* 自定义导出Excel数据注解
*
* 支持EasyExcel和POI双模式
*
* @author ruoyi
*/
@Retention(RetentionPolicy.RUNTIME)
@@ -85,7 +85,7 @@ public @interface Excel
public String prompt() default "";
/**
* 是否允许内容换行
* 是否允许内容换行
*/
public boolean wrapText() default false;
@@ -125,29 +125,29 @@ public @interface Excel
public ColumnType cellType() default ColumnType.STRING;
/**
* 导出列头背景颜色
* 导出列头背景颜色 (EasyExcel使用字符串: "grey_50_percent", "white", etc.)
*/
public IndexedColors headerBackgroundColor() default IndexedColors.GREY_50_PERCENT;
public String headerBackgroundColor() default "grey_50_percent";
/**
* 导出列头字体颜色
* 导出列头字体颜色 (EasyExcel使用字符串: "white", "black", etc.)
*/
public IndexedColors headerColor() default IndexedColors.WHITE;
public String headerColor() default "white";
/**
* 导出单元格背景颜色
* 导出单元格背景颜色 (EasyExcel使用字符串: "white", "yellow", etc.)
*/
public IndexedColors backgroundColor() default IndexedColors.WHITE;
public String backgroundColor() default "white";
/**
* 导出单元格字体颜色
* 导出单元格字体颜色 (EasyExcel使用字符串: "black", "red", etc.)
*/
public IndexedColors color() default IndexedColors.BLACK;
public String color() default "black";
/**
* 导出字段对齐方式
* 导出字段对齐方式 (EasyExcel使用字符串: "left", "center", "right")
*/
public HorizontalAlignment align() default HorizontalAlignment.CENTER;
public String align() default "center";
/**
* 自定义数据处理器
@@ -176,7 +176,7 @@ public @interface Excel
public int value()
{
return this.value;
return value;
}
}
@@ -192,7 +192,7 @@ public @interface Excel
public int value()
{
return this.value;
return value;
}
}
}
}

View File

@@ -1,24 +1,22 @@
package com.ruoyi.common.utils.poi;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Workbook;
/**
* Excel数据格式处理适配器
*
* 支持EasyExcel和POI双模式
*
* @author ruoyi
*/
public interface ExcelHandlerAdapter
{
/**
* 格式化
*
*
* @param value 单元格数据值
* @param args excel注解args参数组
* @param cell 单元格对象
* @param wb 工作簿对象
* @param cell 单元格对象 (POI: org.apache.poi.ss.usermodel.Cell, EasyExcel: com.alibaba.excel.enums.CellDataType)
* @param wb 工作簿对象 (POI: org.apache.poi.ss.usermodel.Workbook, EasyExcel: com.alibaba.excel.write.metadata.WriteWorkbook)
*
* @return 处理后的值
*/
Object format(Object value, String[] args, Cell cell, Workbook wb);
Object format(Object value, String[] args, Object cell, Object wb);
}