Excel.java 3.4 KB

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