解讀easyexcel中的常用注解
更新時間:2024年04月18日 09:15:15 作者:想養(yǎng)一只!
這篇文章主要介紹了關(guān)于easyexcel中的常用注解,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
easyexcel中的常用注解
@ExcelProperty
- @ColumnWith 列寬
- @ContentFontStyle 文本字體樣式
- @ContentLoopMerge 文本合并
- @ContentRowHeight 文本行高度
- @ContentStyle 文本樣式
- @HeadFontStyle 標(biāo)題字體樣式
- @HeadRowHeight 標(biāo)題高度
- @HeadStyle 標(biāo)題樣式
- @ExcelIgnore 忽略項
- @ExcelIgnoreUnannotated 忽略未注解
字段注解 | 類注解 |
---|---|
@ColumnWith(列寬) | @ColumnWidth(全局列寬) |
@ExcelProperty(字段配置) | @HeadFontStyle(頭樣式) |
@HeadRowHeight(標(biāo)題高度) | |
@ContentFontStyle(內(nèi)容字體樣式) | |
@ContentRowHeight(內(nèi)容高度) |
@ExcelProperty
必要的一個注解,注解中有三個參數(shù)value,index分別代表列明,列序號
value和index只能二選一,通常不用設(shè)置converter
- 1.value 通過標(biāo)題文本對應(yīng)
- 2.index 通過文本行號對應(yīng)
@ExcelProperty(value = "人員姓名",index = 1) private String comparisonName;
@ColumnWith
設(shè)置列寬度,只有一個參數(shù)value,value的單位是字符長度,最大可以設(shè)置255個字符,因為一個excel單元格最大可以寫入的字符個數(shù)就是255個字符
public class ImeiEncrypt { @ColumnWidth(value = 18) private String imei; }
@ContentFontStyle
用于設(shè)置單元格內(nèi)容字體格式的注解
參數(shù) | 含義 |
---|---|
fontName | 字體名稱 |
fontHeightInPoints | 字體高度 |
italic | 是否斜體 |
strikeout | 是否設(shè)置刪除水平線 |
color | 字體顏色 |
typeOffset | 偏移量 |
underline | 下劃線 |
bold | 是否加粗 |
charset | 編碼格式 |
@ContentStyle
設(shè)置內(nèi)容格式注解
參數(shù) | 含義 |
---|---|
dataFormat | 日期格式 |
hidden | 設(shè)置單元格使用此樣式隱藏 |
locked | 設(shè)置單元格使用此樣式鎖定 |
quotePrefix | 在單元格前面增加`符號,數(shù)字或公式將以字符串形式展示 |
horizontalAlignment | 設(shè)置是否水平居中 |
wrapped | 設(shè)置文本是否應(yīng)換行。將此標(biāo)志設(shè)置為true通過在多行上顯示使單元格中的所有內(nèi)容可見 |
verticalAlignment | 設(shè)置是否垂直居中 |
rotation | 設(shè)置單元格中文本旋轉(zhuǎn)角度。03版本的Excel旋轉(zhuǎn)角度區(qū)間為-90°90°,07版本的Excel旋轉(zhuǎn)角度區(qū)間為0°180° |
indent | 設(shè)置單元格中縮進(jìn)文本的空格數(shù) |
borderLeft | 設(shè)置左邊框的樣式 |
borderRight | 設(shè)置右邊框樣式 |
borderTop | 設(shè)置上邊框樣式 |
borderBottom | 設(shè)置下邊框樣式 |
leftBorderColor | 設(shè)置左邊框顏色 |
rightBorderColor | 設(shè)置右邊框顏色 |
topBorderColor | 設(shè)置上邊框顏色 |
bottomBorderColor | 設(shè)置下邊框顏色 |
fillPatternType | 設(shè)置填充類型 |
fillBackgroundColor | 設(shè)置背景色 |
fillForegroundColor | 設(shè)置前景色 |
shrinkToFit | 設(shè)置自動單元格自動大小 |
@HeadFontStyle
用于定制標(biāo)題字體格式
參數(shù) | 含義 |
---|---|
fontName | 設(shè)置字體名稱 |
fontHeightInPoints | 設(shè)置字體高度 |
italic | 設(shè)置字體是否斜體 |
strikeout | 是否設(shè)置刪除線 |
color | 設(shè)置字體顏色 |
typeOffset | 設(shè)置偏移量 |
underline | 設(shè)置下劃線 |
charset | 設(shè)置字體編碼 |
bold | 設(shè)置字體是否加粗 |
@ExcelIgnore
不將該字段轉(zhuǎn)換成Excel
總結(jié)
以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
MybatisPlus,無XML分分鐘實現(xiàn)CRUD操作
這篇文章主要介紹了MybatisPlus,無XML分分鐘實現(xiàn)CRUD操作,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-08-08