This project has moved and is read-only. For the latest updates, please go here.

error when creating excel file from existing excel file

Jan 26, 2015 at 9:15 PM
Hello,
I am trying to create file from exists excel file. But i got an error message

I have code such as ;
            string path = Server.MapPath("/");
            FileInfo dosya = new FileInfo(path + "personelbilgi.xlsx");
            if( dosya.Exists){
                Response.Write("dosya var");
            }
            ExcelPackage xlsDosya = new ExcelPackage(dosya, true);

            ExcelWorksheet sheet = xlsDosya.Workbook.Worksheets[1];

            sheet.Cells["C3"].Value = "SÜLEYMAN";

            Response.Clear();
            Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
            Response.AddHeader("content-disposition", "attachment;  filename=Analiz.xlsx");
            Response.BinaryWrite(xlsDosya.GetAsByteArray());
            Response.End();
but i got this error message;
[ArgumentException: Aynı anahtara sahip öğe zaten eklenmiş.]
System.ThrowHelper.ThrowArgumentException(ExceptionResource resource) +52
System.Collections.Generic.Dictionary2.Insert(TKey key, TValue value, Boolean add) +11187358
System.Collections.Generic.Dictionary
2.Add(TKey key, TValue value) +10
OfficeOpenXml.Packaging.ZipPackageRelationshipCollection.Add(ZipPackageRelationship item) +72
OfficeOpenXml.Packaging.ZipPackageRelationshipBase.CreateRelationship(Uri targetUri, TargetMode targetMode, String relationshipType) +219
OfficeOpenXml.Packaging.ZipPackagePart.CreateRelationship(Uri targetUri, TargetMode targetMode, String relationshipType) +58
OfficeOpenXml.ExcelWorkbook.Save() +1218
OfficeOpenXml.ExcelPackage.GetAsByteArray(Boolean save) +114
OfficeOpenXml.ExcelPackage.GetAsByteArray() +41
ExcelRead.Default2.Page_Load(Object sender, EventArgs e) in d:\proje\ExcelRead\ExcelRead\Default2.aspx.cs:27
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +51
System.Web.UI.Control.OnLoad(EventArgs e) +92
System.Web.UI.Control.LoadRecursive() +54
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +772
what could i do?

thank you