1 2 3 4 5 6 7 8 9 10 11 12
| 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(); |
Partager