Package com.independentsoft.office

# Class NumberFormatText

java.lang.Object
com.independentsoft.office.NumberFormatText

public class NumberFormatText extends Object
Port of the C# NumberFormatText engine (NumberFormatText.cs). Renders a value the way Excel displays it by applying a SpreadsheetML number format (a built-in numFmtId or a custom formatCode). Never throws: an unparsable code falls back to General.

C# declares the class internal; Java has no assembly scope, so it is public here for the same reason `Util` is. Method names follow the C# original to keep the port faithful. Where C# returns a colour through an out parameter, the Java signature takes a one-element String array instead, which may be null when the caller does not want it.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `NumberFormatText()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static String`
  `formatGeneral​(double value)`
  Excel's General format: up to 11 significant digits, switching to scientific notation for very large or very small magnitudes.
  `static String`
  `formatNumber​(double value, String code, boolean date1904, String[] colorOverride)`
  Formats a numeric value (or a date/time serial) for display.
  `static String`
  `formatText​(String text, String code, String[] colorOverride)`
  Formats a text value.
  `static String`
  `getBuiltInFormatCode​(int id)`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### NumberFormatText

    public NumberFormatText()

- ## Method Details

  - ### getBuiltInFormatCode

    public static String getBuiltInFormatCode​(int id)

  - ### formatNumber

    public static String formatNumber​(double value, String code, boolean date1904, String[] colorOverride)
    Formats a numeric value (or a date/time serial) for display.
    Parameters:
      `value` - the value to format.
      `code` - the number format code.
      `date1904` - true if the workbook uses the 1904 date system.
      `colorOverride` - optional one-element array that receives the colour the format asks for ("#RRGGBB"), or null.
    Returns:
      the displayed text.

  - ### formatText

    public static String formatText​(String text, String code, String[] colorOverride)
    Formats a text value. Only the fourth (text) section applies; without one the text is displayed unchanged.
    Parameters:
      `text` - the text to format.
      `code` - the number format code.
      `colorOverride` - optional one-element array that receives the colour the format asks for ("#RRGGBB"), or null.
    Returns:
      the displayed text.

  - ### formatGeneral

    public static String formatGeneral​(double value)
    Excel's General format: up to 11 significant digits, switching to scientific notation for very large or very small magnitudes.
    Parameters:
      `value` - the value to format.
    Returns:
      the displayed text.