Specified part does not exist in the project

Dec 21, 2011 at 9:09 PM
Edited Dec 21, 2011 at 9:09 PM

When I try to run this simple program.


using (ExcelPackage package = new ExcelPackage(existingFile))
            ExcelWorksheet worksheet = package.Workbook.Worksheets["Sheet1"];
            worksheet.Cells["A1"].Value = "TEST";
I get the following error when the save command is called.
[InvalidOperationException: Specified part does not exist in the package.]
   System.IO.Packaging.Package.GetPart(Uri partUri) +3204174
   OfficeOpenXml.Drawing.ExcelPicture..ctor(ExcelDrawings drawings, XmlNode node) +224
   OfficeOpenXml.Drawing.ExcelDrawing.GetDrawing(ExcelDrawings drawings, XmlNode node) +158
   OfficeOpenXml.Drawing.ExcelDrawings.AddDrawings() +144
   OfficeOpenXml.ExcelWorksheet.get_Drawings() +63
   OfficeOpenXml.ExcelWorksheet.Save() +209
   OfficeOpenXml.ExcelWorkbook.Save() +443
   OfficeOpenXml.ExcelPackage.Save() +139

[InvalidOperationException: Error saving file C:\inetpub\Project\output.xlsx]
   OfficeOpenXml.ExcelPackage.Save() +1090
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +115
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +140
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String
	 eventArgument) +29
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, 
	Boolean includeStagesAfterAsyncPoint) +2981
The same error occurs when I try to use SaveAs. I am using version and the 
same error also occurs using version  Any ideas on what might be causing this problem?
Jan 4, 2012 at 3:29 PM

I have figured out that the problem had to do with the excel file I was working with.  It contained lots of complex formulas and formatting which I believe were causing problems.  When I tried working with a simplified version of the file it worked as expected.