As the subject says, when using
using (Stream output = new FileStream(excelFileInfo.FullName, FileMode.OpenOrCreate, FileAccess.Write))
{
new XlsxFormatProvider().Export(workbook, output);
}Sometimes the resulting Excel file is corrupted and cannot be imported again. I couldn't figure out a pattern so far because it is not with every export of changes in the excel workbook. This issue appears at least since Telerik Version 2025.4.1321.80
The issue seems not to appear in Telerik Version 2024.2.426.70 or earlier.
When the file is corrupted, opening in MS Excel shows the repair dialog.
Attempting to import it via Telerik XlsxFormatProvider throws an Exception:
System.IO.InvalidDataException: Number of entries expected in End Of Central Directory does not correspond to number of entries in Central Directory.
It seems to be some issue with the internal Zip File handling.
Stack Trace:
at System.IO.Compression.ZipArchive.ReadCentralDirectoryPostOuterLoopWork(Int64 numberOfEntries)
at System.IO.Compression.ZipArchive.ReadCentralDirectory()
at System.IO.Compression.ZipArchive.get_Entries()
at Telerik.Windows.Documents.FormatProviders.OpenXml.OpenXmlImporter`1.GetZipEntries(ZipArchive archive)
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, CancellationToken cancellationToken)
at Telerik.Windows.Documents.Spreadsheet.FormatProviders.WorkbookFormatProviderBase.Import(Stream input, Nullable`1 timeout)
