Créer de nouvelles présentations avec VSTO et Aspose.Slides pour .NET

Création d’une présentation

Voici deux exemples de code illustrant comment VSTO et Aspose.Slides for .NET peuvent être utilisés pour atteindre le même objectif. Le premier exemple est VSTO; le deuxième exemple utilise Aspose.Slides.

Exemple VSTO

La sortie VSTO

todo:image_alt_text

//Remarque : PowerPoint est un espace de noms qui a été défini ci‑dessus ainsi
//using PowerPoint = Microsoft.Office.Interop.PowerPoint;

//Créer une présentation
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);

Exemple Aspose.Slides for .NET

La sortie d’Aspose.Slides

todo:image_alt_text

//Créer une présentation
Presentation pres = new Presentation();

//Ajouter la diapositive titre
ISlide slide = pres.Slides.AddEmptySlide(pres.LayoutSlides[0]);


//Définir le texte du titre
((IAutoShape)slide.Shapes[0]).TextFrame.Text = "Slide Title Heading";

//Définir le texte du sous-titre
((IAutoShape)slide.Shapes[1]).TextFrame.Text = "Slide Title Sub-Heading";

//Écrire la sortie sur le disque
pres.Save("c:\\data\\outAsposeSlides.pptx", SaveFormat.Ppt);