源碼地址:
com.alibaba.excel.annotation
注解講解:
@ContentRowHeight(int):
設置 row 高度,不包含表頭
標記在 類上
@HeadRowHeight(int):
設置 表頭 高度(與 @ContentRowHeight 相反)
標記在 類上
@ColumnWidth(int):
設置列寬
標記在屬性上
@ExcelProperty(value = String[], index = int):
設置表頭信息
value: 表名稱
index: 列號
代碼演示:
@Data @ContentRowHeight(50) // 設置 Cell 高度 為50 @HeadRowHeight(40) // 設置表頭 高度 為 40 public class CaseTempMode { @ColumnWidth(13) // 設置 Cell 寬度 @ExcelProperty(value = { "模塊一" }, index = 0) // 設置 表頭 信息 private String model1 ; @ColumnWidth(13) @ExcelProperty(value = { "模塊二" }, index = 1) private String model2; @ColumnWidth(13) @ExcelProperty(value = { "模塊三"}, index = 2) private String model3; @ColumnWidth(13) @ExcelProperty(value = { "模塊四"}, index = 3) private String model4; @ColumnWidth(13) @ExcelProperty(value = { "用例名稱"}, index = 4) private String caseName; @ColumnWidth(13) @ExcelProperty(value = { "用例類型"}, index = 5) private String caseType; @ColumnWidth(17) @ExcelProperty(value = { "用例編號(初始)"}, index = 6) private String initNo; @ColumnWidth(8) @ExcelProperty(value ={ "分值"}, index = 7) private String value; @ColumnWidth(17) @ExcelProperty(value = { "預置條件"}, index = 8) private String term; @ColumnWidth(17) @ExcelProperty(value = { "測試步驟"}, index = 9) private String step; @ColumnWidth(17) @ExcelProperty(value = { "預期結果"}, index = 10) private String result; }
還有兩個注解(目前沒用過,不過從名稱中可以知道是做什么的):
@DateTimeFormat:
@NumberFormat:
效果展示:

具體實現的代碼,自行百度,這里就不展示了(我會記錄到其他博客中,這里只講注解
若工作中要用到其他注解,后續會進行更新...
