Version: Radzen.Blazor 11.2.8 (also checked 11.4.2 — same behavior for this specific issue)
Component: RadzenSpreadsheet
Summary:
When a cell has Format.NumberFormat = "@" (Text) set, typing or pasting a value like 0071, 123., or 12/34 directly into that cell still gets number/date-inferred and loses the leading zero / trailing character — exactly as if no format were set at all. This differs from Excel's own behavior, where a Text-formatted column keeps typed input as literal text with no extra step needed.
Root cause (traced through source):
Cell.SetValue(string) decides how to store a typed/pasted value using only the string's own content:
- If it starts with
'→ forced to literal text (CellData.FromString), no parsing. - If it starts with
=→ treated as a formula. - Otherwise → passed to the
Valuesetter →new CellData(value, culture)→Infer()/TryConvertFromString(), which tries number → date → bool → text, in that order.
At no point does this path read cell.Format/NumberFormat. So a Text-formatted cell and an unformatted cell behave identically for fresh input — the format only affects how an already-stored value is displayed (CellView.razor's GetDisplayValue()), never how new input is parsed.
Repro:
- Set a cell's
FormattoNumberFormat = "@". - Click the cell and type
0071(no leading apostrophe). - Cell shows
71,Cell.ValueTypeisNumber— same as if the format were never set.
What we tried as a workaround:
A custom SpreadsheetCellType (via RadzenSpreadsheet.CellTypes) with a custom editor that forces Context.CommitAsync("'" + typedText) on commit — this does work, but only after reverse-engineering several undocumented internal contracts:
- The editor's root element must be
contenteditableand carry the exact classrz-spreadsheet-editor-input— this is required forSpreadsheet.onFocusIn's buffered-keystroke flush (for the "click a cell and start typing before F2/double-click" case) to target it at all; a plain<input>silently drops those keystrokes. - The
materialtheme sets.rz-spreadsheet-editor-input { color: rgba(0,0,0,0) }(fully transparent), expecting a separate.rz-spreadsheet-editor-highlightoverlay to do the actual visible rendering — a custom editor without that overlay needs its owncoloroverride or the typed text is invisible. Spreadsheet.onKeyDown's global handler callsEditor.StartEdit(address, key)for every printable keystroke wheneverisGridContextis true — which is also true while focus is inside the editor itself — repeatedly stomping the sharedEditor.Value. A custom editor has to stop propagation on ordinary editing keys at the element level to avoid this, which also incidentally works around Backspace/Delete being intercepted by the grid's own shortcut handling.
This worked but felt like it was fighting the framework rather than using a supported extension point, and cost several rounds of debugging to get right.
Question:
Is there a supported, simpler way to make cell input respect Format.NumberFormat (specifically "@"/Text) the way Excel itself does — either built into Cell.SetValue, or via some documented hook we're missing? If a custom cell type really is the intended mechanism for this, would it be possible to document the class/CSS pairing and the isGridContext/keydown behavior above, since neither is currently documented and both are easy to get wrong in a way that silently breaks (invisible text, dropped keystrokes) rather than erroring?
Happy to share a minimal repro project if useful.