Excel Error when opening after save

Oct 25, 2013 at 2:08 PM
Hi

My code strips out formulas from a excel document, runs fine on normal sheets but it excel gives the message "We found a problem with some content"

It seems to be when there is pictures in the excel document, if possible I will mail you the excel document.

The problem occurs even if I take out the iterations.
using (Stream input = File.OpenRead(fileName))
            {
                
                using (ExcelPackage excelPackageRead = new ExcelPackage(input))
                {
                    ExcelWorkbook workbook = excelPackageRead.Workbook;
                    if (workbook != null)
                    {
                        foreach (var workSheet in workbook.Worksheets)
                        {
                            foreach (var cell in workSheet.Cells)
                            {
                                if (!string.IsNullOrEmpty(workSheet.Cells[cell.FullAddress].Formula))
                                {
                                    Console.WriteLine(cell.FullAddress);
                                    Console.WriteLine(workSheet.Cells[cell.FullAddress].Formula);
                                    workSheet.Cells[cell.FullAddress].Value = cell.Value;
                                }
                            }
                        }
                    }
                    //excelPackageRead.Save();
                    FileInfo toWriteFile = new FileInfo(@"D:\test.xlsx");
                    excelPackageRead.SaveAs(toWriteFile);
                }
            }