Nieuwe presentaties maken met VSTO en Aspose.Slides voor .NET

Creating a Presentation

Hieronder staan twee code-voorbeelden die illustreren hoe VSTO en Aspose.Slides voor .NET kunnen worden gebruikt om hetzelfde resultaat te behalen. Het eerste voorbeeld is VSTO; het tweede voorbeeld gebruikt Aspose.Slides.

VSTO-voorbeeld

De VSTO-output

todo:image_alt_text

//Opmerking: PowerPoint is een namespace die hierboven op deze manier is gedefinieerd
//using PowerPoint = Microsoft.Office.Interop.PowerPoint;

//Maak een presentatie
PowerPoint.Presentation pres = Globals.ThisAddIn.Application
	.Presentations.Add(Microsoft.Office.Core.MsoTriState.msoFalse);

//Get the title slide layout
PowerPoint.CustomLayout layout = pres.SlideMaster.
	CustomLayouts[PowerPoint.PpSlideLayout.ppLayoutTitle];

//Add a title slide.
PowerPoint.Slide slide = pres.Slides.AddSlide(1, layout);

//Set the title text
slide.Shapes.Title.TextFrame.TextRange.Text = "Slide Title Heading";

//Set the sub title text
slide.Shapes[2].TextFrame.TextRange.Text = "Slide Title Sub-Heading";

//Write the output to disk
pres.SaveAs("c:\\outVSTO.ppt",
	PowerPoint.PpSaveAsFileType.ppSaveAsPresentation,
	Microsoft.Office.Core.MsoTriState.msoFalse);

Aspose.Slides voor .NET-voorbeeld

De output van Aspose.Slides

todo:image_alt_text

//Maak een presentatie
Presentation pres = new Presentation();

//Voeg de titeldia toe
ISlide slide = pres.Slides.AddEmptySlide(pres.LayoutSlides[0]);


//Stel de titeltekst in
((IAutoShape)slide.Shapes[0]).TextFrame.Text = "Slide Title Heading";

//Stel de subtiteltekst in
((IAutoShape)slide.Shapes[1]).TextFrame.Text = "Slide Title Sub-Heading";

//Schrijf de output naar schijf
pres.Save("c:\\data\\outAsposeSlides.pptx", SaveFormat.Ppt);