|
|
|
1
|
+package com.ruoyi.common.annotation;
|
|
|
|
2
|
+
|
|
|
|
3
|
+import com.ruoyi.common.utils.poi.ExcelHandlerAdapter;
|
|
|
|
4
|
+
|
|
|
|
5
|
+import java.lang.annotation.ElementType;
|
|
|
|
6
|
+import java.lang.annotation.Retention;
|
|
|
|
7
|
+import java.lang.annotation.RetentionPolicy;
|
|
|
|
8
|
+import java.lang.annotation.Target;
|
|
|
|
9
|
+import java.math.BigDecimal;
|
|
|
|
10
|
+
|
|
|
|
11
|
+/**
|
|
|
|
12
|
+ * 自定义导出Excel数据注解
|
|
|
|
13
|
+ *
|
|
|
|
14
|
+ * @author ruoyi
|
|
|
|
15
|
+ */
|
|
|
|
16
|
+@Retention(RetentionPolicy.RUNTIME)
|
|
|
|
17
|
+@Target(ElementType.FIELD)
|
|
|
|
18
|
+public @interface Excel
|
|
|
|
19
|
+{
|
|
|
|
20
|
+ /**
|
|
|
|
21
|
+ * 导出时在excel中排序
|
|
|
|
22
|
+ */
|
|
|
|
23
|
+ public int sort() default Integer.MAX_VALUE;
|
|
|
|
24
|
+
|
|
|
|
25
|
+ /**
|
|
|
|
26
|
+ * 导出到Excel中的名字.
|
|
|
|
27
|
+ */
|
|
|
|
28
|
+ public String name() default "";
|
|
|
|
29
|
+
|
|
|
|
30
|
+ /**
|
|
|
|
31
|
+ * 日期格式, 如: yyyy-MM-dd
|
|
|
|
32
|
+ */
|
|
|
|
33
|
+ public String dateFormat() default "";
|
|
|
|
34
|
+
|
|
|
|
35
|
+ /**
|
|
|
|
36
|
+ * 如果是字典类型,请设置字典的type值 (如: sys_user_sex)
|
|
|
|
37
|
+ */
|
|
|
|
38
|
+ public String dictType() default "";
|
|
|
|
39
|
+
|
|
|
|
40
|
+ /**
|
|
|
|
41
|
+ * 读取内容转表达式 (如: 0=男,1=女,2=未知)
|
|
|
|
42
|
+ */
|
|
|
|
43
|
+ public String readConverterExp() default "";
|
|
|
|
44
|
+
|
|
|
|
45
|
+ /**
|
|
|
|
46
|
+ * 分隔符,读取字符串组内容
|
|
|
|
47
|
+ */
|
|
|
|
48
|
+ public String separator() default ",";
|
|
|
|
49
|
+
|
|
|
|
50
|
+ /**
|
|
|
|
51
|
+ * BigDecimal 精度 默认:-1(默认不开启BigDecimal格式化)
|
|
|
|
52
|
+ */
|
|
|
|
53
|
+ public int scale() default -1;
|
|
|
|
54
|
+
|
|
|
|
55
|
+ /**
|
|
|
|
56
|
+ * BigDecimal 舍入规则 默认:BigDecimal.ROUND_HALF_EVEN
|
|
|
|
57
|
+ */
|
|
|
|
58
|
+ public int roundingMode() default BigDecimal.ROUND_HALF_EVEN;
|
|
|
|
59
|
+
|
|
|
|
60
|
+ /**
|
|
|
|
61
|
+ * 导出类型(0数字 1字符串)
|
|
|
|
62
|
+ */
|
|
|
|
63
|
+ public ColumnType cellType() default ColumnType.STRING;
|
|
|
|
64
|
+
|
|
|
|
65
|
+ /**
|
|
|
|
66
|
+ * 导出时在excel中每个列的高度 单位为字符
|
|
|
|
67
|
+ */
|
|
|
|
68
|
+ public double height() default 14;
|
|
|
|
69
|
+
|
|
|
|
70
|
+ /**
|
|
|
|
71
|
+ * 导出时在excel中每个列的宽 单位为字符
|
|
|
|
72
|
+ */
|
|
|
|
73
|
+ public double width() default 16;
|
|
|
|
74
|
+
|
|
|
|
75
|
+ /**
|
|
|
|
76
|
+ * 文字后缀,如% 90 变成90%
|
|
|
|
77
|
+ */
|
|
|
|
78
|
+ public String suffix() default "";
|
|
|
|
79
|
+
|
|
|
|
80
|
+ /**
|
|
|
|
81
|
+ * 当值为空时,字段的默认值
|
|
|
|
82
|
+ */
|
|
|
|
83
|
+ public String defaultValue() default "";
|
|
|
|
84
|
+
|
|
|
|
85
|
+ /**
|
|
|
|
86
|
+ * 提示信息
|
|
|
|
87
|
+ */
|
|
|
|
88
|
+ public String prompt() default "";
|
|
|
|
89
|
+
|
|
|
|
90
|
+ /**
|
|
|
|
91
|
+ * 设置只能选择不能输入的列内容.
|
|
|
|
92
|
+ */
|
|
|
|
93
|
+ public String[] combo() default {};
|
|
|
|
94
|
+
|
|
|
|
95
|
+ /**
|
|
|
|
96
|
+ * 是否导出数据,应对需求:有时我们需要导出一份模板,这是标题需要但内容需要用户手工填写.
|
|
|
|
97
|
+ */
|
|
|
|
98
|
+ public boolean isExport() default true;
|
|
|
|
99
|
+
|
|
|
|
100
|
+ /**
|
|
|
|
101
|
+ * 另一个类中的属性名称,支持多级获取,以小数点隔开
|
|
|
|
102
|
+ */
|
|
|
|
103
|
+ public String targetAttr() default "";
|
|
|
|
104
|
+
|
|
|
|
105
|
+ /**
|
|
|
|
106
|
+ * 是否自动统计数据,在最后追加一行统计数据总和
|
|
|
|
107
|
+ */
|
|
|
|
108
|
+ public boolean isStatistics() default false;
|
|
|
|
109
|
+
|
|
|
|
110
|
+ /**
|
|
|
|
111
|
+ * 导出字段对齐方式(0:默认;1:靠左;2:居中;3:靠右)
|
|
|
|
112
|
+ */
|
|
|
|
113
|
+ public Align align() default Align.AUTO;
|
|
|
|
114
|
+
|
|
|
|
115
|
+ /**
|
|
|
|
116
|
+ * 自定义数据处理器
|
|
|
|
117
|
+ */
|
|
|
|
118
|
+ public Class<?> handler() default ExcelHandlerAdapter.class;
|
|
|
|
119
|
+
|
|
|
|
120
|
+ /**
|
|
|
|
121
|
+ * 自定义数据处理器参数
|
|
|
|
122
|
+ */
|
|
|
|
123
|
+ public String[] args() default {};
|
|
|
|
124
|
+
|
|
|
|
125
|
+ public enum Align
|
|
|
|
126
|
+ {
|
|
|
|
127
|
+ AUTO(0), LEFT(1), CENTER(2), RIGHT(3);
|
|
|
|
128
|
+ private final int value;
|
|
|
|
129
|
+
|
|
|
|
130
|
+ Align(int value)
|
|
|
|
131
|
+ {
|
|
|
|
132
|
+ this.value = value;
|
|
|
|
133
|
+ }
|
|
|
|
134
|
+
|
|
|
|
135
|
+ public int value()
|
|
|
|
136
|
+ {
|
|
|
|
137
|
+ return this.value;
|
|
|
|
138
|
+ }
|
|
|
|
139
|
+ }
|
|
|
|
140
|
+
|
|
|
|
141
|
+ /**
|
|
|
|
142
|
+ * 字段类型(0:导出导入;1:仅导出;2:仅导入)
|
|
|
|
143
|
+ */
|
|
|
|
144
|
+ Type type() default Type.ALL;
|
|
|
|
145
|
+
|
|
|
|
146
|
+ public enum Type
|
|
|
|
147
|
+ {
|
|
|
|
148
|
+ ALL(0), EXPORT(1), IMPORT(2);
|
|
|
|
149
|
+ private final int value;
|
|
|
|
150
|
+
|
|
|
|
151
|
+ Type(int value)
|
|
|
|
152
|
+ {
|
|
|
|
153
|
+ this.value = value;
|
|
|
|
154
|
+ }
|
|
|
|
155
|
+
|
|
|
|
156
|
+ public int value()
|
|
|
|
157
|
+ {
|
|
|
|
158
|
+ return this.value;
|
|
|
|
159
|
+ }
|
|
|
|
160
|
+ }
|
|
|
|
161
|
+
|
|
|
|
162
|
+ public enum ColumnType
|
|
|
|
163
|
+ {
|
|
|
|
164
|
+ NUMERIC(0), STRING(1), IMAGE(2);
|
|
|
|
165
|
+ private final int value;
|
|
|
|
166
|
+
|
|
|
|
167
|
+ ColumnType(int value)
|
|
|
|
168
|
+ {
|
|
|
|
169
|
+ this.value = value;
|
|
|
|
170
|
+ }
|
|
|
|
171
|
+
|
|
|
|
172
|
+ public int value()
|
|
|
|
173
|
+ {
|
|
|
|
174
|
+ return this.value;
|
|
|
|
175
|
+ }
|
|
|
|
176
|
+ }
|
|
|
|
177
|
+} |