SheetXL - v0.8.0-beta.9+sites.210.e2d420901
    Preparing search index...

    Function encodeFormattedNumber

    • Encodes a number that came off a range carrying a number format — an aggregate, a bound, a value with no cell of its own to ask.

      Parameters

      • value: number
      • OptionalnumberFormat: string | null

      Returns string

      This is what stops a date column from reporting itself as an ID column. A profile that prints 45293 … 46234 for a date series is not merely ugly: it is the wrong type, and a reader acts on it. The same rule fixes currency ($1.20) and percent (42.37%) for free, because there is only one rule — a range's own format decides how its numbers print, exactly as CellEncoding.Mode.Display decides it for a cell.

      General (or no format) falls through to encodeNumber, which is the correct answer for a derived value: a mean carries no format of its own, and Excel's 15-digit display cap is the only thing standing between the reader and the float's binary residue.

      It goes through the SDK's own NumberFormat.getEngine | format engine rather than a format library directly, and that is not incidental: a range's format is frequently a named preset (Short Date, [$-F800]) whose expansion is locale-dependent, and a raw pattern formatter renders Short Date as literal characters — 00ort 1at2024 where the grid shows 1/1/2024. The engine is the only thing that knows the workbook's answer.

      The result is trimmed: alignment formats pad with _) and a trailing space is a cell-width device with no meaning inside a sentence. A format the engine cannot render degrades to the unformatted number — a report must not fail because one column has a broken format string.