From 3f5dbf4973c9ebfe7f7170d7e49302b4a036a240 Mon Sep 17 00:00:00 2001 From: GowthamPonrajSF5414 Date: Fri, 13 Feb 2026 02:58:21 +0530 Subject: [PATCH 1/2] 992569-RemoveCorruptImg --- ...ted-embedded-images-before-saving-excel.md | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 Document-Processing/Excel/Excel-Library/NET/faqs/how-to-remove-the-corrupted-embedded-images-before-saving-excel.md diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-remove-the-corrupted-embedded-images-before-saving-excel.md b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-remove-the-corrupted-embedded-images-before-saving-excel.md new file mode 100644 index 000000000..d15504983 --- /dev/null +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-remove-the-corrupted-embedded-images-before-saving-excel.md @@ -0,0 +1,40 @@ +--- +title: Remove corrupted embedded images before saving | Syncfusion +description: Code example to remove corrupted embedded images before saving an Excel file using the Syncfusion .NET Excel library (XlsIO). +platform: document-processing +control: XlsIO +documentation: UG +--- + +# How to remove corrupted embedded images before saving? + +The following code example demonstrate how to remove the corrupted embedded images before saving an Excel file using C# (Cross-platform). + +{% tabs %} +{% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/XlsIO-Examples/master/FAQ/Remove%20corrupted%20images/.NET/RemoveCorruptedImages/RemoveCorruptedImages/Program.cs,180" %} +using (ExcelEngine excelEngine = new ExcelEngine()) +{ + IApplication application = excelEngine.Excel; + application.DefaultVersion = ExcelVersion.Xlsx; + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/Input.xlsx")); + + foreach (IWorksheet sheet in workbook.Worksheets) + { + for (int i = 0; i < sheet.Pictures.Count; i++) + { + if (sheet.Pictures[i].Picture != null && sheet.Pictures[i].Picture.ImageData.Length <= 0) + { + // Remove corrupted image. + sheet.Pictures[i].Remove(); + } + } + } + + // Save the workbook. + workbook.SaveAs(Path.GetFullPath(@"Output/Output.xlsx")); +} +{% endhighlight %} + +{% endtabs %} + +A complete working example in C# is present on this GitHub page. \ No newline at end of file From 5a344a7d9d879af8fe1d49279b274c31d3d62aec Mon Sep 17 00:00:00 2001 From: MOHAN CHANDRAN <93247949+Mohan2401@users.noreply.github.com> Date: Fri, 13 Feb 2026 19:13:29 +0530 Subject: [PATCH 2/2] Update how-to-remove-the-corrupted-embedded-images-before-saving-excel.md --- ...emove-the-corrupted-embedded-images-before-saving-excel.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-remove-the-corrupted-embedded-images-before-saving-excel.md b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-remove-the-corrupted-embedded-images-before-saving-excel.md index d15504983..ebb95114d 100644 --- a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-remove-the-corrupted-embedded-images-before-saving-excel.md +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-remove-the-corrupted-embedded-images-before-saving-excel.md @@ -6,7 +6,7 @@ control: XlsIO documentation: UG --- -# How to remove corrupted embedded images before saving? +# How to remove corrupted embedded images before saving an Excel document? The following code example demonstrate how to remove the corrupted embedded images before saving an Excel file using C# (Cross-platform). @@ -37,4 +37,4 @@ using (ExcelEngine excelEngine = new ExcelEngine()) {% endtabs %} -A complete working example in C# is present on this GitHub page. \ No newline at end of file +A complete working example in C# is present on this GitHub page.