VSTO と Aspose.Slides で新しいプレゼンテーションを作成する

以下は、VSTO と Aspose.Slides for .NET を使用して同じ目的を達成する方法を示す 2 つのコード例です。

VSTO


 private void CreatePresentation()

{

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("outVSTO.ppt",

	PowerPoint.PpSaveAsFileType.ppSaveAsPresentation,

	Microsoft.Office.Core.MsoTriState.msoFalse);

}

Aspose.Slides


 private static void CreatePresentation()

{

	//Create a presentation

	Presentation pres = new Presentation();

	//Add the title slide

	Slide slide = pres.AddTitleSlide();

	//Set the title text

	((TextHolder)slide.Placeholders[0]).Text = "Slide Title Heading";

	//Set the sub title text

	((TextHolder)slide.Placeholders[1]).Text = "Slide Title Sub-Heading";

	//Write output to disk

	pres.Write("outAsposeSlides.ppt");

}

サンプルコードをダウンロード