Excel.java 3.9 KB

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