@@ -47,51 +47,52 @@ using GroupDocs.Editor.Formats;
4747using GroupDocs .Editor .Options ;
4848// ...
4949
50- // Load input spreadsheet to the Editor and specify loading options
51- using (Editor editor = new Editor (" Input3Worksheets.xlsx " , new SpreadsheetLoadOptions ()))
50+ // Load input presentation to the Editor and specify loading options
51+ using (Editor editor = new Editor (" Presentations-Tips.ppt " , new PresentationLoadOptions ()))
5252{
53- // Prepare edit options and set 2nd worksheet to edit
54- SpreadsheetEditOptions editOptions = new SpreadsheetEditOptions ();
55- editOptions .WorksheetIndex = 1 ;// 2nd worksheet to edit, here WorksheetIndex is 0-based due to historical reasons
53+ // Prepare edit options and set 2nd slide to edit
54+ PresentationEditOptions editOptions = new PresentationEditOptions ();
55+ editOptions .ShowHiddenSlides = true ;
56+ editOptions .SlideNumber = 1 ;// 2nd slide to edit, here SlideNumber is 0-based due to historical reasons
5657
57- // generate EditableDocument with original content of 2nd worksheet
58- using (EditableDocument worksheet2OpenedForEdit = editor .Edit (editOptions ))
58+ // generate EditableDocument with original content of 2nd slide
59+ using (EditableDocument slide2OpenedForEdit = editor .Edit (editOptions ))
5960 {
6061 // Get the HTML-markup from the EditableDocument with original content
61- string originalHtmlContentOf2ndWorksheet = worksheet2OpenedForEdit .GetEmbeddedHtml ();
62-
62+ string originalHtmlContentOf2ndSlide = slide2OpenedForEdit .GetEmbeddedHtml ();
63+
6364 // emulate HTML content editing in WYSIWYG-editor in browser or somewhere else
64- string editedHtmlContentOf2ndWorksheet = originalHtmlContentOf2ndWorksheet .Replace (" 2nd row " , " Edited 2nd row at 1st column " );
65+ string editedHtmlContentOf2ndSlide = originalHtmlContentOf2ndSlide .Replace (" Tips to be Covered " , " Edited tips on 2nd slide " );
6566
66- // generate EditableDocument with edited content of 2nd worksheet
67- using (EditableDocument worksheet2AfterEdit = EditableDocument .FromMarkup (editedHtmlContentOf2ndWorksheet ))
67+ // generate EditableDocument with edited content of 2nd slide
68+ using (EditableDocument slide2AfterEdit = EditableDocument .FromMarkup (editedHtmlContentOf2ndSlide ))
6869 {
6970 // prepare save options without deletions
70- SpreadsheetSaveOptions saveOptionsWithoutDelete = new SpreadsheetSaveOptions ( SpreadsheetFormats . Xlsx );
71- // let it be the 2nd worksheet ...
72- saveOptionsWithoutDelete .WorksheetNumber = 2 ;// here WorksheetNumber is 1-based
73- // ... and we also save the original 2nd worksheet , which is pushed to the 3rd position
74- saveOptionsWithoutDelete .InsertAsNewWorksheet = true ;
71+ PresentationSaveOptions saveOptionsWithoutDelete = new PresentationSaveOptions ( PresentationFormats . Pptx );
72+ // let it be the 2nd slide ...
73+ saveOptionsWithoutDelete .SlideNumber = 2 ;// here SlideNumber is 1-based
74+ // ... and we also save the original 2nd slide , which is pushed to the 3rd position
75+ saveOptionsWithoutDelete .InsertAsNewSlide = true ;
7576
76- // So now the spreadsheet must have 4 worksheets , not 3 . Save it to file
77- editor .Save (worksheet2AfterEdit , " Output4Worksheets -without-delete.xlsx " , saveOptionsWithoutDelete );
77+ // So now the presentation must have 22 slides , not 21 . Save it to file
78+ editor .Save (slide2AfterEdit , " Output22Slides -without-delete.pptx " , saveOptionsWithoutDelete );
7879
7980 // Create another save options, with deletions at this time
80- SpreadsheetSaveOptions saveOptionsWithDelete = new SpreadsheetSaveOptions ( SpreadsheetFormats . Xlsx );
81- // let the new worksheet will be 2nd for now, but after deleting it will became the 1st later
82- saveOptionsWithDelete .WorksheetNumber = 2 ;
81+ PresentationSaveOptions saveOptionsWithDelete = new PresentationSaveOptions ( PresentationFormats . Pptx );
82+ // let the new slide will be 2nd for now, but after deleting it will became the 1st later
83+ saveOptionsWithDelete .SlideNumber = 2 ;
8384
84- // ... and we also save the original 2nd worksheet , which will be next sibling to the newly inserted
85- saveOptionsWithDelete .InsertAsNewWorksheet = true ;
85+ // ... and we also save the original 2nd slide , which will be next sibling to the newly inserted
86+ saveOptionsWithDelete .InsertAsNewSlide = true ;
8687
87- // delete the 1st and last worksheet
88- saveOptionsWithDelete .WorksheetNumbersToDelete = new int [2 ]
88+ // delete the 1st and last slide
89+ saveOptionsWithDelete .SlideNumbersToDelete = new int [2 ]
8990 {
90- 1 ,// 1st worksheet
91- 4 // last worksheet is 4 , not 3 , because we inserted the edited 2nd worksheet as the new worksheet instance, without rewriting the original 2nd worksheet
91+ 1 ,// 1st slide
92+ 22 // last slide is 22 , not 21 , because we inserted the edited 2nd slide as the new slide instance, without rewriting the original 2nd slide
9293 };
93- // Save it again to distinct file. Output XLSX should have 2 worksheets now.
94- editor .Save (worksheet2AfterEdit , " Output2Worksheets -with-delete.xlsx " , saveOptionsWithDelete );
94+ // Save it again to distinct file. Output PPTX should have 20 slides now.
95+ editor .Save (slide2AfterEdit , " Output20Slides -with-delete.pptx " , saveOptionsWithDelete );
9596 }
9697 }
9798}
@@ -104,47 +105,48 @@ Imports GroupDocs.Editor.Formats
104105Imports GroupDocs.Editor.Options
105106' ...
106107
107- ' Load input spreadsheet to the Editor and specify loading options
108- Using editor As New Editor( "Input3Worksheets.xlsx" , New SpreadsheetLoadOptions())
109- ' Prepare edit options and set 2nd worksheet to edit
110- Dim editOptions As New SpreadsheetEditOptions()
111- editOptions.WorksheetIndex = 1 '2nd worksheet to edit, here WorksheetIndex is 0-based due to historical reasons
108+ ' Load input presentation to the Editor and specify loading options
109+ Using editor As New Editor( "Presentations-Tips.ppt" , New PresentationLoadOptions())
110+ ' Prepare edit options and set 2nd slide to edit
111+ Dim editOptions As New PresentationEditOptions
112+ editOptions.ShowHiddenSlides = True
113+ editOptions.SlideNumber = 1 '2nd slide to edit, here SlideNumber is 0-based due to historical reasons
112114
113- ' generate EditableDocument with original content of 2nd worksheet
114- Using worksheet2OpenedForEdit As EditableDocument = editor.Edit(editOptions)
115+ ' generate EditableDocument with original content of 2nd slide
116+ Using slide2OpenedForEdit As EditableDocument = editor.Edit(editOptions)
115117 ' Get the HTML-markup from the EditableDocument with original content
116- Dim originalHtmlContentOf2ndWorksheet As String = worksheet2OpenedForEdit .GetEmbeddedHtml()
118+ Dim originalHtmlContentOf2ndSlide As String = slide2OpenedForEdit .GetEmbeddedHtml()
117119
118120 ' emulate HTML content editing in WYSIWYG-editor in browser or somewhere else
119- Dim editedHtmlContentOf2ndWorksheet As String = originalHtmlContentOf2ndWorksheet .Replace("2nd row " , "Edited 2nd row at 1st column " )
121+ Dim editedHtmlContentOf2ndSlide As String = originalHtmlContentOf2ndSlide .Replace("Tips to be Covered " , "Edited tips on 2nd slide " )
120122
121- ' generate EditableDocument with edited content of 2nd worksheet
122- Using worksheet2AfterEdit As EditableDocument = EditableDocument.FromMarkup(editedHtmlContentOf2ndWorksheet )
123+ ' generate EditableDocument with edited content of 2nd slide
124+ Using slide2AfterEdit As EditableDocument = EditableDocument.FromMarkup(editedHtmlContentOf2ndSlide )
123125 ' prepare save options without deletions
124- Dim saveOptionsWithoutDelete As New SpreadsheetSaveOptions(SpreadsheetFormats.Xlsx )
126+ Dim saveOptionsWithoutDelete As New PresentationSaveOptions(PresentationFormats.Pptx )
125127
126- ' let it be the 2nd worksheet ...
127- saveOptionsWithoutDelete.WorksheetNumber = 2 'here WorksheetNumber is 1-based
128- '... and we also save the original 2nd worksheet , which is pushed to the 3rd position
129- saveOptionsWithoutDelete.InsertAsNewWorksheet = True
128+ ' let it be the 2nd slide ...
129+ saveOptionsWithoutDelete.SlideNumber = 2
130+ '... and we also save the original 2nd slide , which is pushed to the 3rd position
131+ saveOptionsWithoutDelete.InsertAsNewSlide = True
130132
131- ' So now the spreadsheet must have 4 worksheets , not 3 . Save it to file
132- editor.Save(worksheet2AfterEdit , "Output4Worksheets -without-delete.xlsx " , saveOptionsWithoutDelete)
133+ ' So now the presentation must have 22 slides , not 21 . Save it to file
134+ editor.Save(slide2AfterEdit , "Output22Slides -without-delete.pptx " , saveOptionsWithoutDelete)
133135
134136 ' Create another save options, with deletions at this time
135- Dim saveOptionsWithDelete As New SpreadsheetSaveOptions(SpreadsheetFormats.Xlsx )
136- ' let the new worksheet will be 2nd for now, but after deleting it will became the 1st later
137- saveOptionsWithDelete.WorksheetNumber = 2
138- '... and we also save the original 2nd worksheet , which will be next sibling to the newly inserted
139- saveOptionsWithDelete.InsertAsNewWorksheet = True
140-
141- ' delete the 1st and last worksheet
142- saveOptionsWithDelete.WorksheetNumbersToDelete = New Int32( 1 ) {
143- 1 , '1st worksheet
144- 4 'last worksheet is 4 , not 3 , because we inserted the edited 2nd worksheet as the new worksheet instance, without rewriting the original 2nd worksheet
137+ Dim saveOptionsWithDelete As New PresentationSaveOptions(PresentationFormats.Pptx )
138+ ' let the new slide will be 2nd for now, but after deleting it will became the 1st later
139+ saveOptionsWithDelete.SlideNumber = 2
140+ '... and we also save the original 2nd slide , which will be next sibling to the newly inserted
141+ saveOptionsWithDelete.InsertAsNewSlide = True
142+
143+ 'delete the 1st and last slide
144+ saveOptionsWithDelete.SlideNumbersToDelete = New Int32( 1 ) {
145+ 1 , ' 1St slide
146+ 22 'last slide is 22 , not 21 , because we inserted the edited 2nd slide as the new slide instance, without rewriting the original 2nd slide
145147 }
146- ' Save it again to distinct file. Output XLSX should have 2 worksheets now.
147- editor.Save(worksheet2AfterEdit , "Output2Worksheets -with-delete.xlsx " , saveOptionsWithDelete)
148+ ' Save it again to distinct file. Output PPTX should have 20 slides now.
149+ editor.Save(slide2AfterEdit , "Output20Slides -with-delete.pptx " , saveOptionsWithDelete)
148150 End Using
149151 End Using
150152End Using
0 commit comments