New to Telerik Document ProcessingStart a free 30-day trial

Resolve Exporting Corrupted Excel Files With SpreadProcessing

Updated on Sep 19, 2025

Environment

VersionProductAuthor
2025.2.520RadSpreadProcessingDesislava Yordanova

Description

Exporting an Excel file using Telerik SpreadProcessing shows a corruption warning when opening the file in Excel.

This issue occurs when reusing the same MemoryStream for both import and export operations without resetting or truncating the stream. The issue originates in version 2025.2.520, where Telerik.Zip was replaced with System.IO.Compression.

This knowledge base article shows how to fix the "Excel found unreadable content" error after export.

Solution

To ensure the exported files are not corrupted, reset or truncate the MemoryStream before export, or use a new stream. Follow these steps:

  1. Reset and Truncate the Stream: Before exporting, truncate the MemoryStream to remove residual content and reset its position. Use the following code:

    csharp
    XlsxFormatProvider formatProvider = new XlsxFormatProvider();
    
    using (Workbook workbook = formatProvider.Import(memoryStream))
    {
        memoryStream.SetLength(0);    // Truncate stream to remove previous content
        memoryStream.Position = 0;    // Reset position to start
        formatProvider.Export(workbook, memoryStream);
        formatProvider = null;
    }
  2. Use a New MemoryStream for Export: Alternatively, create a new MemoryStream for exporting to avoid residual data issues:

    csharp
    XlsxFormatProvider formatProvider = new XlsxFormatProvider();
    using (Workbook workbook = formatProvider.Import(memoryStream))
    {
        using (MemoryStream newMemoryStream = new MemoryStream())
        {
            formatProvider.Export(workbook, newMemoryStream);
            // Use newMemoryStream for further processing
        }
        formatProvider = null;
    }

See Also