From fedc63e7b87f7c61e426276dd67d639f6b593ef4 Mon Sep 17 00:00:00 2001 From: KB Bot Date: Thu, 14 Aug 2025 11:36:45 +0000 Subject: [PATCH 1/8] Added new kb article resolving-excel-file-corruption-warning-after-spreadprocessing-export --- ...n-warning-after-spreadprocessing-export.md | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 knowledge-base/resolving-excel-file-corruption-warning-after-spreadprocessing-export.md diff --git a/knowledge-base/resolving-excel-file-corruption-warning-after-spreadprocessing-export.md b/knowledge-base/resolving-excel-file-corruption-warning-after-spreadprocessing-export.md new file mode 100644 index 00000000..e7eccbf8 --- /dev/null +++ b/knowledge-base/resolving-excel-file-corruption-warning-after-spreadprocessing-export.md @@ -0,0 +1,68 @@ +--- +title: Fixing Corrupt Excel Files After Export Using Telerik SpreadProcessing +description: Resolving issues where exported Excel files using Telerik SpreadProcessing show corruption warnings after upgrading to version 2025.2.520. +type: how-to +page_title: Resolving Excel File Corruption Warning After SpreadProcessing Export +meta_title: Resolving Excel File Corruption Warning After SpreadProcessing Export +slug: resolving-excel-file-corruption-warning-after-spreadprocessing-export +tags: telerik-document-processing, spreadprocessing, excel-export, memory-stream, corrupted-file +res_type: kb +ticketid: 1695962 +--- + +## Environment +| Version | Product | Author | +| ---- | ---- | ---- | +| 2025.2.520| RadSpreadProcessing |[Desislava Yordanova](https://www.telerik.com/blogs/author/desislava-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 problem started after upgrading to version 2025.2.520 due to changes in the library that replaced `Telerik.Zip` with `System.IO.Compression`. + +This knowledge base article also answers the following questions: +- How to fix "Excel found unreadable content" errors after export? +- Why does my exported Excel file open with a corruption warning? +- How to resolve MemoryStream issues with Telerik SpreadProcessing? + +## 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; + } + ``` + +### Additional Notes: +- If you are not explicitly using the [RadZipLibrary](https://docs.telerik.com/devtools/document-processing/libraries/radziplibrary/overview), you can safely remove its reference in your project. Starting with version 2025.2.520, Telerik Document Processing Libraries use `System.IO.Compression` internally. + +## See Also + +- [Telerik SpreadProcessing Documentation](https://docs.telerik.com/devtools/document-processing/libraries/spreadprocessing/overview) +- [RadZipLibrary Documentation](https://docs.telerik.com/devtools/document-processing/libraries/radziplibrary/overview) +- [Release Notes for Telerik Document Processing Libraries 2025.2.520](https://www.telerik.com/support/whats-new/telerik-document-processing/release-history/progress-telerik-document-processing-2025-2-520-changelog) From 6167846b5355113eb465373af7d66bbb9f68ca5b Mon Sep 17 00:00:00 2001 From: Desislava Yordanova Date: Wed, 27 Aug 2025 18:07:06 +0300 Subject: [PATCH 2/8] polished --- ...ption-warning-after-spreadprocessing-export.md | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/knowledge-base/resolving-excel-file-corruption-warning-after-spreadprocessing-export.md b/knowledge-base/resolving-excel-file-corruption-warning-after-spreadprocessing-export.md index e7eccbf8..175a9025 100644 --- a/knowledge-base/resolving-excel-file-corruption-warning-after-spreadprocessing-export.md +++ b/knowledge-base/resolving-excel-file-corruption-warning-after-spreadprocessing-export.md @@ -17,12 +17,11 @@ ticketid: 1695962 ## 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 problem started after upgrading to version 2025.2.520 due to changes in the library that replaced `Telerik.Zip` with `System.IO.Compression`. +Exporting an Excel file using Telerik [SpreadProcessing]({%slug radspreadprocessing-overview%}) shows a corruption warning when opening the file in Excel. -This knowledge base article also answers the following questions: -- How to fix "Excel found unreadable content" errors after export? -- Why does my exported Excel file open with a corruption warning? -- How to resolve MemoryStream issues with Telerik SpreadProcessing? +This issue occurs when reusing the same `MemoryStream` for both import and export operations without resetting or truncating the stream. The problem started after upgrading to version 2025.2.520 due to changes in the library that replaced `Telerik.Zip` with `System.IO.Compression`. + +This knowledge base article shows how to fix "Excel found unreadable content" errors after export. ## Solution @@ -58,11 +57,7 @@ To ensure the exported files are not corrupted, reset or truncate the `MemoryStr } ``` -### Additional Notes: -- If you are not explicitly using the [RadZipLibrary](https://docs.telerik.com/devtools/document-processing/libraries/radziplibrary/overview), you can safely remove its reference in your project. Starting with version 2025.2.520, Telerik Document Processing Libraries use `System.IO.Compression` internally. - ## See Also -- [Telerik SpreadProcessing Documentation](https://docs.telerik.com/devtools/document-processing/libraries/spreadprocessing/overview) -- [RadZipLibrary Documentation](https://docs.telerik.com/devtools/document-processing/libraries/radziplibrary/overview) +- [SpreadProcessing]({%slug radspreadprocessing-overview%}) - [Release Notes for Telerik Document Processing Libraries 2025.2.520](https://www.telerik.com/support/whats-new/telerik-document-processing/release-history/progress-telerik-document-processing-2025-2-520-changelog) From 36433fae9273b5e96c2940c75145e8ce1e6d678e Mon Sep 17 00:00:00 2001 From: Desislava Yordanova Date: Wed, 27 Aug 2025 18:08:25 +0300 Subject: [PATCH 3/8] Update resolving-excel-file-corruption-warning-after-spreadprocessing-export.md --- ...cel-file-corruption-warning-after-spreadprocessing-export.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/knowledge-base/resolving-excel-file-corruption-warning-after-spreadprocessing-export.md b/knowledge-base/resolving-excel-file-corruption-warning-after-spreadprocessing-export.md index 175a9025..5dd038fc 100644 --- a/knowledge-base/resolving-excel-file-corruption-warning-after-spreadprocessing-export.md +++ b/knowledge-base/resolving-excel-file-corruption-warning-after-spreadprocessing-export.md @@ -5,7 +5,7 @@ type: how-to page_title: Resolving Excel File Corruption Warning After SpreadProcessing Export meta_title: Resolving Excel File Corruption Warning After SpreadProcessing Export slug: resolving-excel-file-corruption-warning-after-spreadprocessing-export -tags: telerik-document-processing, spreadprocessing, excel-export, memory-stream, corrupted-file +tags: telerik,document,processing, spread, excel,export, memory,stream, corrupted,file res_type: kb ticketid: 1695962 --- From a73eb66ec61825b8a703fb86bcb47b5d43e420ef Mon Sep 17 00:00:00 2001 From: Yoan Karamanov Date: Tue, 9 Sep 2025 17:42:42 +0300 Subject: [PATCH 4/8] Update resolving-excel-file-corruption-warning-after-spreadprocessing-export.md --- ...uption-warning-after-spreadprocessing-export.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/knowledge-base/resolving-excel-file-corruption-warning-after-spreadprocessing-export.md b/knowledge-base/resolving-excel-file-corruption-warning-after-spreadprocessing-export.md index 5dd038fc..d4080713 100644 --- a/knowledge-base/resolving-excel-file-corruption-warning-after-spreadprocessing-export.md +++ b/knowledge-base/resolving-excel-file-corruption-warning-after-spreadprocessing-export.md @@ -1,11 +1,11 @@ --- -title: Fixing Corrupt Excel Files After Export Using Telerik SpreadProcessing -description: Resolving issues where exported Excel files using Telerik SpreadProcessing show corruption warnings after upgrading to version 2025.2.520. +title: Resolve Exporting Corrupted Excel Files With SpreadProcessing +description: Resolve corrupted Excel files exported with SpreadProcessing in versions 2025.2.520 and newer. type: how-to -page_title: Resolving Excel File Corruption Warning After SpreadProcessing Export -meta_title: Resolving Excel File Corruption Warning After SpreadProcessing Export +page_title: Resolve Exporting Corrupted Excel Files With SpreadProcessing +meta_title: Resolve Exporting Corrupted Excel Files With SpreadProcessing slug: resolving-excel-file-corruption-warning-after-spreadprocessing-export -tags: telerik,document,processing, spread, excel,export, memory,stream, corrupted,file +tags: telerik, document, processing, spread, excel, export, memory, stream, corrupted, file res_type: kb ticketid: 1695962 --- @@ -19,9 +19,9 @@ ticketid: 1695962 Exporting an Excel file using Telerik [SpreadProcessing]({%slug radspreadprocessing-overview%}) 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 problem started after upgrading to version 2025.2.520 due to changes in the library that replaced `Telerik.Zip` with `System.IO.Compression`. +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 "Excel found unreadable content" errors after export. +This knowledge base article shows how to fix the "Excel found unreadable content" error after export. ## Solution From d6c9b26fc127630f5d28844dbd69f49b194bddff Mon Sep 17 00:00:00 2001 From: Desislava Yordanova Date: Fri, 19 Sep 2025 11:52:00 +0300 Subject: [PATCH 5/8] Update xlsxformatprovider.md --- .../xlsx/xlsxformatprovider.md | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/radspreadprocessing/formats-and-conversion/import-and-export-to-excel-file-formats/xlsx/xlsxformatprovider.md b/libraries/radspreadprocessing/formats-and-conversion/import-and-export-to-excel-file-formats/xlsx/xlsxformatprovider.md index 82630027..f35bee52 100644 --- a/libraries/radspreadprocessing/formats-and-conversion/import-and-export-to-excel-file-formats/xlsx/xlsxformatprovider.md +++ b/libraries/radspreadprocessing/formats-and-conversion/import-and-export-to-excel-file-formats/xlsx/xlsxformatprovider.md @@ -101,3 +101,4 @@ __Example 2__ demonstrates how to export an existing Workbook to an xlsx file. T * [Import/Load and Export/Save RadSpreadProcessing Workbook]({%slug import-export-save-load-workbook%}) * [Timeout Mechanism]({%slug timeout-mechanism-in-dpl%}) +* [Resolve Exporting Corrupted Excel Files With SpreadProcessing]({%slug resolving-excel-file-corruption-warning-after-spreadprocessing-export%}) From 92dfecf17e92244a99370ef52493ff9d69ab302f Mon Sep 17 00:00:00 2001 From: Dess Date: Fri, 19 Sep 2025 11:52:17 +0300 Subject: [PATCH 6/8] Update resolving-excel-file-corruption-warning-after-spreadprocessing-export.md --- ...el-file-corruption-warning-after-spreadprocessing-export.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/knowledge-base/resolving-excel-file-corruption-warning-after-spreadprocessing-export.md b/knowledge-base/resolving-excel-file-corruption-warning-after-spreadprocessing-export.md index d4080713..5a9cd4d1 100644 --- a/knowledge-base/resolving-excel-file-corruption-warning-after-spreadprocessing-export.md +++ b/knowledge-base/resolving-excel-file-corruption-warning-after-spreadprocessing-export.md @@ -32,8 +32,9 @@ To ensure the exported files are not corrupted, reset or truncate the `MemoryStr ```csharp XlsxFormatProvider formatProvider = new XlsxFormatProvider(); - using (Workbook workbook = formatProvider.Import(memoryStream)) + using (Stream memoryStream = new FileStream("path to your document", FileMode.Open)) { + 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); From 61f58bfeb35499cc90330c2d6c074cda5c9c2eff Mon Sep 17 00:00:00 2001 From: Desislava Yordanova Date: Fri, 19 Sep 2025 12:41:59 +0300 Subject: [PATCH 7/8] Revert "Update resolving-excel-file-corruption-warning-after-spreadprocessing-export.md" This reverts commit 92dfecf17e92244a99370ef52493ff9d69ab302f. --- ...el-file-corruption-warning-after-spreadprocessing-export.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/knowledge-base/resolving-excel-file-corruption-warning-after-spreadprocessing-export.md b/knowledge-base/resolving-excel-file-corruption-warning-after-spreadprocessing-export.md index 5a9cd4d1..d4080713 100644 --- a/knowledge-base/resolving-excel-file-corruption-warning-after-spreadprocessing-export.md +++ b/knowledge-base/resolving-excel-file-corruption-warning-after-spreadprocessing-export.md @@ -32,9 +32,8 @@ To ensure the exported files are not corrupted, reset or truncate the `MemoryStr ```csharp XlsxFormatProvider formatProvider = new XlsxFormatProvider(); - using (Stream memoryStream = new FileStream("path to your document", FileMode.Open)) + using (Workbook workbook = formatProvider.Import(memoryStream)) { - 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); From af2f54bb2020aad3c2ac5dddaf3c6b18ad64a54f Mon Sep 17 00:00:00 2001 From: Desislava Yordanova Date: Fri, 19 Sep 2025 12:43:32 +0300 Subject: [PATCH 8/8] Discussed with Yoan the whole case and reverted the code as it was --- ...cel-file-corruption-warning-after-spreadprocessing-export.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/knowledge-base/resolving-excel-file-corruption-warning-after-spreadprocessing-export.md b/knowledge-base/resolving-excel-file-corruption-warning-after-spreadprocessing-export.md index d4080713..cf993b69 100644 --- a/knowledge-base/resolving-excel-file-corruption-warning-after-spreadprocessing-export.md +++ b/knowledge-base/resolving-excel-file-corruption-warning-after-spreadprocessing-export.md @@ -19,7 +19,7 @@ ticketid: 1695962 Exporting an Excel file using Telerik [SpreadProcessing]({%slug radspreadprocessing-overview%}) 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 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.