Crear nuevas presentaciones usando VSTO y Aspose.Slides para .NET

Crear una presentación

A continuación se muestran dos ejemplos de código que ilustran cómo VSTO y Aspose.Slides for .NET pueden usarse para lograr el mismo objetivo. El primer ejemplo es VSTO; el segundo ejemplo usa Aspose.Slides.

Ejemplo VSTO

La salida de VSTO

todo:image_alt_text

//Nota: PowerPoint es un espacio de nombres que se ha definido arriba de esta manera
//using PowerPoint = Microsoft.Office.Interop.PowerPoint;

//Crear una presentación
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);

Ejemplo Aspose.Slides for .NET

La salida de Aspose.Slides

todo:image_alt_text

//Crear una presentación
Presentation pres = new Presentation();

//Agregar la diapositiva de título
ISlide slide = pres.Slides.AddEmptySlide(pres.LayoutSlides[0]);


//Establecer el texto del título
((IAutoShape)slide.Shapes[0]).TextFrame.Text = "Slide Title Heading";

//Establecer el texto del subtítulo
((IAutoShape)slide.Shapes[1]).TextFrame.Text = "Slide Title Sub-Heading";

//Escribir la salida en disco
pres.Save("c:\\data\\outAsposeSlides.pptx", SaveFormat.Ppt);