Unplanned
Last Updated: 18 Dec 2025 10:13 by Martin Ivanov
Martin Ivanov
Created on: 18 Dec 2025 10:13
Category: RichTextBox
Type: Feature Request
0
RichTextBox: FormatException thrown during table import from a docx document when the app culture is set to Swedish (sv-SE)

FormatException is thrown during the import of a table coming from a docx document when the application culture is "sv-SE". This happens when the column width in the document is a floating point number (ex: 120.65). The Swedish culture uses "," as decimal separator and " " as the number group separator, which makes any invariant decimal value (like 120.65) invalid during standard parsing (ex: float.Parse("120.65")).

Stacktrace:

FormatException: The input string '4514.5' was not in the correct format.
at System.Single.Parse(String s)
Telerik.Windows.Controls.RichTextBox.dll!Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.Import.TableImporter.ImportTableGrid(Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.Parsing.Style style)  Telerik.Windows.Controls.RichTextBox.dll!Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.Import.TableImporter.Import(Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.Parsing.Style parentStyle)  Telerik.Windows.Controls.RichTextBox.dll!Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.Import.MainDocumentImporter.BuildTable(Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.Parsing.Style parentStyle)  Telerik.Windows.Controls.RichTextBox.dll!Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.Import.MainDocumentImporter.BuildBody()  Telerik.Windows.Controls.RichTextBox.dll!Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.Import.MainDocumentImporter.BuildDocument()  Telerik.Windows.Controls.RichTextBox.dll!Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.Import.MainDocumentImporter.Import()Telerik.Windows.Controls.RichTextBox.dll!Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.Import.DocxImporter.ReadXmlContentFromPackage(Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.Import.DocxPartImporterBase importer)  Telerik.Windows.Controls.RichTextBox.dll!Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.Import.DocxImporter.ReadXmlContentAndRelationsFromPackage(Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.Import.DocxPartImporterBase importer)
Telerik.Windows.Controls.RichTextBox.dll!Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.Import.DocxImporter.Import()  Telerik.Windows.Controls.RichTextBox.dll!Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.DocxFormatProvider.Import(System.IO.Stream input) 

To work this around, switch to InvariantCulture during the import and return the original culture after that.

 var cultureCache = Thread.CurrentThread.CurrentCulture;
 Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
 Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.InvariantCulture;
 var provider= new DocxFormatProvider();
 rtb.Document = provider.Import(stream);
 Thread.CurrentThread.CurrentCulture = cultureCache;
 Thread.CurrentThread.CurrentUICulture = cultureCache;

0 comments