类 DataFormatter
- java.lang.Object
-
- com.alibaba.excel.metadata.format.DataFormatter
public class DataFormatter extends Object
Written with reference toDataFormatter
.Made some optimizations for date conversion.This is a non-thread-safe class.
- 作者:
- Jiaju Zhuang
-
构造器概要
构造器 构造器和说明 DataFormatter(Boolean use1904windowing, Locale locale, Boolean useScientificFormat)
Creates a formatter using the given locale.
方法概要
所有方法 静态方法 实例方法 具体方法 限定符和类型 方法和说明 void
addFormat(String excelFormatStr, Format format)
Adds a new format to the available formats.String
format(BigDecimal data, Short dataFormat, String dataFormatString)
Format data.void
setDefaultNumberFormat(Format format)
Sets a default number format to be used when the Excel format cannot be parsed successfully.static void
setExcelStyleRoundingMode(DecimalFormat format)
Enables excel style rounding mode (round half up) on the Decimal Format given.static void
setExcelStyleRoundingMode(DecimalFormat format, RoundingMode roundingMode)
Enables custom rounding mode on the given Decimal Format.
-
方法详细资料
format
public String format(BigDecimal data, Short dataFormat, String dataFormatString)
Format data.- 参数:
-
data
- -
dataFormat
- -
dataFormatString
- - 返回:
setDefaultNumberFormat
public void setDefaultNumberFormat(Format format)
Sets a default number format to be used when the Excel format cannot be parsed successfully. Note: This is a fall back for when an error occurs while parsing an Excel number format pattern. This will not affect cells with the General format.
The value that will be passed to the Format's format method (specified by
java.text.Format#format
) will be a double value from a numeric cell. Therefore the code in the format method should expect aNumber
value.- 参数:
-
format
- A Format instance to be used as a default - 另请参阅:
-
Format.format(java.lang.Object)
addFormat
public void addFormat(String excelFormatStr, Format format)
Adds a new format to the available formats.The value that will be passed to the Format's format method (specified by
java.text.Format#format
) will be a double value from a numeric cell. Therefore the code in the format method should expect aNumber
value.- 参数:
-
excelFormatStr
- The data format string -
format
- A Format instance
setExcelStyleRoundingMode
public static void setExcelStyleRoundingMode(DecimalFormat format)
Enables excel style rounding mode (round half up) on the Decimal Format given.
setExcelStyleRoundingMode
public static void setExcelStyleRoundingMode(DecimalFormat format, RoundingMode roundingMode)
Enables custom rounding mode on the given Decimal Format.- 参数:
-
format
- DecimalFormat -
roundingMode
- RoundingMode
Copyright © 2018–2021 Alibaba Group. All rights reserved.