ایجاد ارائه‌های جدید با استفاده از VSTO و Aspose.Slides برای .NET

ایجاد یک ارائه

در زیر دو مثال کد آورده شده است که نشان می‌دهند چگونه می‌توان از VSTO و Aspose.Slides for .NET برای دستیابی به همان هدف استفاده کرد. مثال اول VSTO است؛ مثال دوم از Aspose.Slides استفاده می‌کند.

مثال VSTO

خروجی VSTO

todo:image_alt_text

//توجه: PowerPoint یک فضای نام است که در بالا به این شکل تعریف شده است
//using PowerPoint = Microsoft.Office.Interop.PowerPoint;

//ایجاد یک ارائه
PowerPoint.Presentation pres = Globals.ThisAddIn.Application
	.Presentations.Add(Microsoft.Office.Core.MsoTriState.msoFalse);

//دریافت قالب اسلاید عنوان
PowerPoint.CustomLayout layout = pres.SlideMaster.
	CustomLayouts[PowerPoint.PpSlideLayout.ppLayoutTitle];

//افزودن یک اسلاید عنوان.
PowerPoint.Slide slide = pres.Slides.AddSlide(1, layout);

//تنظیم متن عنوان
slide.Shapes.Title.TextFrame.TextRange.Text = "Slide Title Heading";

//تنظیم متن زیرعنوان
slide.Shapes[2].TextFrame.TextRange.Text = "Slide Title Sub-Heading";

//نوشتن خروجی در دیسک
pres.SaveAs("c:\\outVSTO.ppt",
	PowerPoint.PpSaveAsFileType.ppSaveAsPresentation,
	Microsoft.Office.Core.MsoTriState.msoFalse);

مثال Aspose.Slides for .NET

خروجی Aspose.Slides

todo:image_alt_text

//ایجاد یک ارائه
Presentation pres = new Presentation();

//Add the title slide
ISlide slide = pres.Slides.AddEmptySlide(pres.LayoutSlides[0]);

//Set the title text
((IAutoShape)slide.Shapes[0]).TextFrame.Text = "Slide Title Heading";

//Set the sub title text
((IAutoShape)slide.Shapes[1]).TextFrame.Text = "Slide Title Sub-Heading";

//Write output to disk
pres.Save("c:\\data\\outAsposeSlides.pptx", SaveFormat.Ppt);