com.alibaba.excel.metadata.format

类 DataFormatter


  • public class DataFormatter
    extends Object
    Written with reference to DataFormatter.Made some optimizations for date conversion.

    This is a non-thread-safe class.

    作者:
    Jiaju Zhuang
    • 构造器详细资料

      • DataFormatter

        public DataFormatter(Boolean use1904windowing,
                             Locale locale,
                             Boolean useScientificFormat)
        Creates a formatter using the given locale.
    • 方法详细资料

      • 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 a Number 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 a Number 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.