Class Cell
java.lang.Object
io.leandev.appfuse.workbook.Cell
儲存格
封裝底層 POI 的 XSSFCell,提供型別感知的讀寫:
- 寫入:
setValue(Object)依執行期型別自動對映(字串、數值、日期、布林) - 讀取:
getValue()依儲存格型別還原為對應 Java 型別(公式會先求值)
樣式設定方法(如 setColor(Color))會在此儲存格上延遲建立一個專屬樣式。
需要大量套用相同外觀時,請改用 Workbook.createCellStyle() + setStyle(CellStyle) 共用樣式。
- Since:
- 4.0.0
-
Method Summary
Modifier and TypeMethodDescription取得目前的資料格式字串getValue()讀取儲存格值row()取得此儲存格所屬的列void設定水平對齊voidsetBackground(Color color) 設定背景填滿顏色voidsetBorderColor(Color color) 設定四邊框線顏色voidsetBorderStyle(BorderStyle borderStyle) 設定四邊框線樣式void設定字型顏色voidsetDataFormat(DataFormat dataFormat) 以預設格式列舉設定資料格式voidsetDataFormat(String dataFormat) 以指定 Excel 格式字串設定資料格式voidsetFontFamily(String name) 設定字型名稱voidsetFontSize(short points) 設定字級(點數)voidsetFormula(String formula) 寫入公式(不含前導=,如A1+B1、SUM(A1:A10))void套用既有(可共用)的儲存格樣式void寫入儲存格值voidsetWrapText(boolean wrapText) 設定是否自動換行
-
Method Details
-
setValue
-
getValue
-
setFormula
寫入公式(不含前導
=,如A1+B1、SUM(A1:A10))公式的計算結果在以
getValue()讀取時才求值。- Parameters:
formula- Excel 公式字串
-
setDataFormat
以指定 Excel 格式字串設定資料格式- Parameters:
dataFormat- Excel 格式字串(如yyyy-mm-dd、#,##0.00)
-
setDataFormat
-
dataFormat
-
setColor
-
setBackground
-
setBorderStyle
-
setBorderColor
-
setAlign
-
setFontFamily
-
setFontSize
public void setFontSize(short points) 設定字級(點數)- Parameters:
points- 字級點數
-
setWrapText
public void setWrapText(boolean wrapText) 設定是否自動換行- Parameters:
wrapText- 是否自動換行
-
setStyle
-
row
-