Class XlsxNumberFormatter
- Namespace
- DocWright.Spreadsheet
- Assembly
- DocWright.Spreadsheet.dll
Shows a value through a number format code as Excel shows it.
public static class XlsxNumberFormatter
- Inheritance
-
XlsxNumberFormatter
- Inherited Members
Remarks
The rules were measured, not read from the specification: 8,372 pairs of a code and a
value, with the text Excel shows for each (tools/Probe-ExcelWorkbooks.ps1 -Formats,
tests/fixtures/xlsx/number-formats.tsv), and the tests run every one of them.
A code is parsed once and kept by its text, up to a fixed number of codes; parsing and formatting cost the length of the code and no more. Nothing here reads the machine's culture: without Culture the output is the same everywhere.
What needs a width. Excel decides three things by the width of the column: how
many digits the general format keeps, how often a * fill is repeated, and whether a
value is too wide to show. The general format is reproduced to the character. The other
two Excel measures in pixels of the cell's font; here they are counted in characters,
which is close and not the same.
Fields
- MaxCodeLength
The longest number format code that is taken: 255 characters, which is Excel's own limit for one.
Methods
- Format(XlsxCellValue, string?, XlsxFormatContext?)
Shows a value through a number format code.