public void CanDoFileBasedClonePresentation() { using (var tempFile = TemporaryFile.Create()) using (var stream = GetStream(TestFiles.Presentation)) using (var source = PresentationDocument.Open(stream, false)) using (source.Clone(tempFile.Path, false)) using (var dest = PresentationDocument.Open(tempFile.Path, false)) { PackageAssert.Equal(source, dest); } }
public void CanDoFileBasedCloneSpreadsheet() { using (var tempFile = TemporaryFile.Create()) using (var stream = GetStream(TestFiles.Spreadsheet)) using (var source = SpreadsheetDocument.Open(stream, false)) using (source.Clone(tempFile.Path, false)) using (var dest = SpreadsheetDocument.Open(tempFile.Path, false)) { PackageAssert.Equal(source, dest); } }
public void CanCreateFlatOpcPresentationDocuments() { using (var inputStream = GetStream(TestFiles.Presentation)) using (var source = PresentationDocument.Open(inputStream, false)) { var flatOpcDoc = source.ToFlatOpcDocument(); using (var dest = PresentationDocument.FromFlatOpcDocument(flatOpcDoc)) { PackageAssert.Equal(source, dest); } } }
public void CanCreateFlatOpcWordprocessingDocuments5() { using (var inputStream = GetStream(TestFiles.Document)) using (var source = WordprocessingDocument.Open(inputStream, false)) { var flatOpcString = source.ToFlatOpcString(); using (var dest = WordprocessingDocument.FromFlatOpcString(flatOpcString)) { PackageAssert.Equal(source, dest); } } }
public void CanCreateFlatOpcDocuments5() { using (var inputStream = GetStream(Path)) using (var source = Open(inputStream, false)) { var flatOpcString = source.ToFlatOpcString(); using (var dest = FromFlatOpcString(flatOpcString)) { PackageAssert.Equal(source, dest); } } }
public void CanCreateFlatOpcSpreadsheetDocuments1() { using (var inputStream = GetStream(TestFiles.Spreadsheet)) using (var source = SpreadsheetDocument.Open(inputStream, false)) { var flatOpcDoc = source.ToFlatOpcDocument(); using (var dest = SpreadsheetDocument.FromFlatOpcDocument(flatOpcDoc)) { PackageAssert.Equal(source, dest); } } }
public void CanCreateFlatOpcWordprocessingDocuments2() { using (var inputStream = GetStream(TestFiles.Document)) using (var source = WordprocessingDocument.Open(inputStream, false)) { var flatOpcDoc = source.ToFlatOpcDocument(); using (Stream stream = new MemoryStream()) using (WordprocessingDocument.FromFlatOpcDocument(flatOpcDoc, stream, false)) using (var dest = WordprocessingDocument.Open(stream, false)) { PackageAssert.Equal(source, dest); } } }
public void CanCreateFlatOpcSpreadsheetDocuments7() { using (var inputStream = GetStream(TestFiles.Spreadsheet)) using (var source = SpreadsheetDocument.Open(inputStream, false)) { var flatOpcString = source.ToFlatOpcString(); using (var tempFile = TemporaryFile.Create()) using (SpreadsheetDocument.FromFlatOpcString(flatOpcString, tempFile.Path, false)) using (var dest = SpreadsheetDocument.Open(tempFile.Path, false)) { PackageAssert.Equal(source, dest); } } }
public void CanCreateFlatOpcSpreadsheetDocuments4() { using (var inputStream = GetStream(TestFiles.Spreadsheet)) using (var source = SpreadsheetDocument.Open(inputStream, false)) using (var stream = new MemoryStream()) using (var package = Package.Open(stream, FileMode.Create, FileAccess.ReadWrite)) { var flatOpcDoc = source.ToFlatOpcDocument(); using (var dest = SpreadsheetDocument.FromFlatOpcDocument(flatOpcDoc, package)) { PackageAssert.Equal(source, dest); } } }
public void CanCreateFlatOpcWordprocessingDocuments3() { using (var inputStream = GetStream(TestFiles.Document)) using (var source = WordprocessingDocument.Open(inputStream, false)) { var flatOpcDoc = source.ToFlatOpcDocument(); using (var tempFile = TemporaryFile.Create()) using (WordprocessingDocument.FromFlatOpcDocument(flatOpcDoc, tempFile.Path, false)) using (var dest = WordprocessingDocument.Open(tempFile.Path, false)) { PackageAssert.Equal(source, dest); } } }
public void CanCreateFlatOpcPresentationDocuments6() { using (var inputStream = GetStream(TestFiles.Presentation)) using (var source = PresentationDocument.Open(inputStream, false)) { var flatOpcString = source.ToFlatOpcString(); using (Stream stream = new MemoryStream()) using (PresentationDocument.FromFlatOpcString(flatOpcString, stream, false)) using (var dest = PresentationDocument.Open(stream, false)) { PackageAssert.Equal(source, dest); } } }
public void CanCreateFlatOpcDocuments2() { using (var inputStream = GetStream(Path)) using (var source = Open(inputStream, false)) { var flatOpcDoc = source.ToFlatOpcDocument(); using (var stream = new MemoryStream()) using (FromFlatOpcDocument(flatOpcDoc, stream, false)) using (var dest = Open(stream, false)) { PackageAssert.Equal(source, dest); } } }
public void CanCreateFlatOpcWordprocessingDocuments8() { using (var inputStream = GetStream(TestFiles.Document)) using (var source = WordprocessingDocument.Open(inputStream, false)) { var flatOpcString = source.ToFlatOpcString(); using (var stream = new MemoryStream()) using (var package = Package.Open(stream, FileMode.Create, FileAccess.ReadWrite)) using (var dest = WordprocessingDocument.FromFlatOpcString(flatOpcString, package)) { PackageAssert.Equal(source, dest); } } }
public void CanSaveAsPowerpoint() { using (var stream = GetStream(TestFiles.Presentation)) using (var source = PresentationDocument.Open(stream, false)) using (var tempFile = TemporaryFile.Create()) { using (source.SaveAs(tempFile.Path)) { } using (var dest = PresentationDocument.Open(tempFile.Path, false)) { PackageAssert.Equal(source, dest); } } }
public void CanSaveAsExcel() { using (var tempFile = TemporaryFile.Create()) using (var stream = GetStream(TestFiles.Spreadsheet)) using (var source = SpreadsheetDocument.Open(stream, false)) { using (source.SaveAs(tempFile.Path)) { } using (var dest = SpreadsheetDocument.Open(tempFile.Path, false)) { PackageAssert.Equal(source, dest); } } }
public void CanSaveAsWord() { using (var tempFile = TemporaryFile.Create()) using (var stream = GetStream(TestFiles.Document)) using (var source = WordprocessingDocument.Open(stream, false)) { using (source.SaveAs(tempFile.Path)) { } using (var dest = WordprocessingDocument.Open(tempFile.Path, false)) { PackageAssert.Equal(source, dest); } } }
public void CanCreateFlatOpcDocumentsDynamically() { using (var stream = new MemoryStream()) using (var document = Create(stream)) { AddMainPart(document); document.Save(); string opc = document.ToFlatOpcString(); using (var dest = FromFlatOpcString(opc)) { PackageAssert.Equal(document, dest); } } }
public void CanDoStreamBasedCloningPowerpoint() { using (var stream = GetStream(TestFiles.Presentation)) using (var source = PresentationDocument.Open(stream, false)) using (var memoryStream = new MemoryStream()) { using (source.Clone(memoryStream, false)) { } memoryStream.Position = 0; using (var dest = PresentationDocument.Open(memoryStream, false)) { PackageAssert.Equal(source, dest); } } }
public void CanDoStreamBasedCloningExcel() { using (var stream = GetStream(TestFiles.Spreadsheet)) using (var source = SpreadsheetDocument.Open(stream, false)) using (var memoryStream = new MemoryStream()) { using (source.Clone(memoryStream, true)) { } memoryStream.Position = 0; using (var dest = SpreadsheetDocument.Open(memoryStream, false)) { PackageAssert.Equal(source, dest); } } }
public void CanDoStreamBasedCloningWord() { using (var stream = GetStream(TestFiles.Document)) using (var source = WordprocessingDocument.Open(stream, false)) using (var memoryStream = new MemoryStream()) { using (source.Clone(memoryStream, true)) { } memoryStream.Position = 0; using (var dest = WordprocessingDocument.Open(memoryStream, false)) { PackageAssert.Equal(source, dest); } } }
public void CanDoPackageBasedCloningPowerpoint() { using (var stream = GetStream(TestFiles.Presentation, true)) using (var source = PresentationDocument.Open(stream, true)) using (var ms = new MemoryStream()) { using (var package = Package.Open(ms, FileMode.Create)) { source.Clone(package).Close(); } ms.Position = 0; using (var destination = PresentationDocument.Open(ms, true)) { PackageAssert.Equal(source, destination); } } }
public void CanCloneDocument() { using (var file = TemporaryFile.Create()) { using (var stream = GetStream(TestFiles.Document)) using (var source = WordprocessingDocument.Open(stream, false)) using (var clone = (WordprocessingDocument)source.Clone()) { var body = clone.MainDocumentPart.Document.Body; body.InsertBefore(new Paragraph(new Run(new Text("Hello World"))), body.FirstChild); clone.SaveAs(file.Path).Close(); using (var dest = WordprocessingDocument.Open(file.Path, false)) { PackageAssert.NotEqual(source, dest); } } } }
public void CanCloneDocument() { using (var file = TemporaryFile.Create()) { using (var stream = GetStream(TestFiles.Document)) using (var source = WordprocessingDocument.Open(stream, false)) using (var clone = (WordprocessingDocument)source.Clone()) { var body = clone.MainDocumentPart.Document.Body; body.InsertBefore(new Paragraph(new Run(new Text("Hello World"))), body.FirstChild); clone.SaveAs(file.Path).Close(); using (var dest = WordprocessingDocument.Open(file.Path, false)) { // We want the documents to be different. Assert.Throws <Xunit.Sdk.EqualException>(() => PackageAssert.Equal(source, dest)); } } } }
public void CanCreateFlatOpcDocumentsDynamically() { using (var stream = new MemoryStream()) using (var document = Create(stream)) { AddMainPart(document); document.Save(); if (OpenXmlPackage.CanSave) { string opc = document.ToFlatOpcString(); using (var dest = FromFlatOpcString(opc)) { PackageAssert.Equal(document, dest); } } else { Assert.Throws <IOException>(() => document.ToFlatOpcString()); } } }