Modify an openxml Excel file
Hello,
I've a problem to modify a sheet in my Excel document. All the files present in the package are removed when I execute this code :
Package pkgOutputDoc = Package.Open(fileName, FileMode.Create, FileAccess.ReadWrite);
Uri uri = new Uri(string.Format("/xl/worksheets/sheet{0}.xml", sheetNumber), UriKind.Relative);
PackagePart partSheetXml = pkgOutputDoc.CreatePart(uri, "application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml");
StreamWriter streamStartPart = new StreamWriter(partSheetXml.GetStream(FileMode.Create, FileAccess.Write));
xmlStartPart.Save(streamStartPart);
streamStartPart.Close();
pkgOutputDoc.Flush();
pkgOutputDoc.CreateRelationship(uri, TargetMode.Internal,
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument",
"rId1");
pkgOutputDoc.Flush();
pkgOutputDoc.Close();
I don't want to create a new openxml Excel file. I just want to modify a sheet. Could you tell me what is wrong in the above code ?
Thanks for any help,
mathmax

