NumberFormat class

An Excel number format code (ECMA-376 Part 1, §18.8.31), e.g. #,##0.00, 0%, m/d/yyyy or $#,##0_);[Red]($#,##0), and how a number looks under it.

Covers what spreadsheets use day to day: General, digit placeholders (0 # ?), thousands separators and scaling commas, percent, scientific, fractions, literal text, up to four ; sections (positive; negative; zero; text) with conditions, colours (ignored), currency tags, and dates, times and elapsed time. Locale-specific built-in formats use their en-US look.

Constructors

NumberFormat(String code)
Wraps a format code as written in the file.
const

Properties

code → String
The format code, e.g. #,##0.00 (a <numFmt formatCode>).
final
hashCode → int
The hash code for this object.
no setteroverride
isDate → bool
Whether this formats numbers as dates or times.
no setter
isGeneral → bool
Whether this is the General format (or an empty code).
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

format(num value, {bool date1904 = false}) → String
value under this format. A date format places value as days since 1900-01-00, or since 1904-01-01 with date1904.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
override

Operators

operator ==(Object other) → bool
The equality operator.
override

Static Methods

builtIn(int id) → NumberFormat?
The format for a built-in numFmtId (§18.8.30), or null when the id isn't built in (the file then defines it in <numFmts>).
formatGeneral(num value) → String
Excel's General format: integers as-is, other numbers to 10 significant digits, and very large/small ones in scientific notation.

Constants

general → const NumberFormat
Excel's default format (numFmtId 0).