Last Updated: 10 May 2023 15:06 by ADMIN
Created on: 08 May 2023 20:09
Category: Telerik Document Processing
Type: Bug Report
XslxFormatProvider Import throws an exception

When importing an XLSX that has "Date" number-formatted cells, and those cells have the 5-digit representation of th edate, XslxFormatProvider.Import(bytes) will throw a KeyNotFoundException. The exception message is "The given key '58' was not present in the dictionary" for the particular case we're looking at.

Unfortunately, we cannot provide the file itself, as it has PHI in it. And, when we open it in Excel and resave it, Excel will automatically convert the 5-digit representation to a normal date. This new file will import just fine. However, we're trying to cut out that intermediate step.

Pertinent portion of the stack trace:
   at System.ThrowHelper.ThrowKeyNotFoundException[T](T key)

   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at Telerik.Windows.Documents.Spreadsheet.FormatProviders.OpenXml.Xlsx.Contexts.XlsxWorksheetImportContext.ImportDirectFormattingInRange(XlsxWorkbookImportContext workbookContext, FormattingRecord directFormatting, PropertyBagBase propertyBag, Int64 start, Int64 end)
   at Telerik.Windows.Documents.Spreadsheet.FormatProviders.OpenXml.Xlsx.Contexts.XlsxWorksheetImportContext.EndImport(XlsxWorkbookImportContext workbookContext)
   at Telerik.Windows.Documents.Spreadsheet.FormatProviders.OpenXml.Xlsx.Contexts.XlsxWorkbookImportContext.EndImport()
   at Telerik.Windows.Documents.FormatProviders.OpenXml.OpenXmlImporter`1.Import(Stream input, IOpenXmlImportContext context)
   at Telerik.Windows.Documents.Spreadsheet.FormatProviders.OpenXml.Xlsx.XlsxFormatProvider.ImportOverride(Stream input)
   at Telerik.Windows.Documents.Spreadsheet.FormatProviders.WorkbookFormatProviderBase.Import(Stream input)
   at Telerik.Windows.Documents.Spreadsheet.FormatProviders.BinaryWorkbookFormatProviderBase.Import(Byte[] input)
   at .....



1 comment
Posted on: 10 May 2023 15:06

Hello Chris,

I apologize for the inconvenience but without a sample document for examination, I am unable to make any concrete statements and conclusions regarding this behavior you are experiencing. I can assure you that we treat all resources our clients share with confidentiality and for testing purposes only (as per our EULA section 11). That being said is it somehow possible for you to provide us with a file I can work with? An alternative I can offer is to remove any sensitive information directly from the document structure if possible and then share it with us (trying to keep the file unmodified by Excel).

Looking forward to your reply. Thank you for your understanding.

Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.