Skip to main content

Module numfmt

Module numfmt 

Source
Expand description

GridCraft number formats: Excel format codes (#,##0.00;[Red](#,##0.00), dates, fractions, scientific…), the General display format and the TEXT() worksheet function. en-US only.

Structs§

Formatted
A formatted value ready to paint.
NumberFormat
A parsed number format code. Cheap to clone.

Enums§

FormatColor
Colour from a [Red] or [ColorN] section tag.
FormatKind
Best guess at the ribbon’s number-format category.

Constants§

MAX_FORMAT_CODE_CHARS
Longest number format code, in characters (not bytes), that is parsed: Excel’s own limit. A longer code is invalid: NumberFormat::parse returns a General format (the cell shows its value unformatted; the stored code is kept as is) and TEXT returns #VALUE!. The cap also bounds every allocation that scales with the number of placeholders in a code.

Functions§

builtin_format
Built-in format code for an id (0..=49, en-US), e.g. 14 => “m/d/yyyy”. Locale-specific ids (23–36) and unknown ids return None.
builtin_id
Id of a built-in format code. Matching ignores case and backslash escapes.
format_general_fit
General format squeezed into max_chars characters. Excel shows fewer decimals, then scientific notation, then “####” when a column is narrow; None means the caller paints “####”.
format_value
Formats a cell value for display.
text_function
The TEXT() worksheet function: formats a value with a format code. Numeric text is converted to a number first; other text and booleans (as TRUE/FALSE) go through the text section, or are returned as is.