PPT处理控件Aspose.Slides功能演示:使用C#或VB.NET合并PowerPoint演示文稿

合并PowerPoint演示文稿在各种情况下很有用,例如合并来自多个PPT / PPTX的内容,合并由两个或更多人创建的单个演示文稿的各个部分等。

PPT处理控件Aspose.Slides功能演示:使用C#或VB.NET合并PowerPoint演示文稿

  • 使用C#合并PowerPoint演示文稿
  • 使用C#合并PowerPoint演示文稿的特定幻灯片
  • 合并PowerPoint演示文稿时使用幻灯片母版

让人兴奋的是整合所有格式API处理套包Aspose.Slides正在 火热销售中,新购优惠折上折!联系客服立马1分钟了解全部咨询!


使用C#合并PowerPoint演示文稿

在本节中,将学习如何将所有幻灯片从一个PowerPoint演示文稿克隆和合并到另一幻灯片。为此,可以简单地从源演示文稿中克隆幻灯片并将其添加到目标演示文稿的末尾。以下是合并两个演示文稿的步骤。

  • 创建Presentation类的对象以加载目标演示文件。
  • 创建另一个Presentation对象,以从中克隆幻灯片的位置加载源演示。
  • 使用Presentation.Slides属性访问源演示文稿中的幻灯片集合。
  • 遍历幻灯片集合,并使用Presentation.Slides.AddClone(ISlide)方法将它们合并到目标演示文稿中。
  • 使用Presentation.Save(String,SaveFormat)方法保存合并的演示文稿。

下面的代码示例演示如何使用C#合并两个PowerPoint演示文稿。

// Instantiate a Presentation object that represents a target presentation fileusing (Presentation presentation1 = new Presentation("presentation1.pptx")){  // Instantiate a Presentation object that represents a source presentation fileusing (Presentation presentation2 = new Presentation("presentation2.pptx")){foreach (ISlide slide in presentation2.Slides){      // Merge slides from source to targetpresentation1.Slides.AddClone(slide);}}  // Save the presentationpresentation1.Save("merged-presentation.pptx", Export.SaveFormat.Pptx);}

目标介绍

PPT处理控件Aspose.Slides功能演示:使用C#或VB.NET合并PowerPoint演示文稿

PPT处理控件Aspose.Slides功能演示:使用C#或VB.NET合并PowerPoint演示文稿

合并简

PPT处理控件Aspose.Slides功能演示:使用C#或VB.NET合并PowerPoint演示文稿

使用C#合并PowerPoint演示文稿的特定幻灯片

在某些情况下,只需要合并选定的幻灯片即可。在这种情况下,可以使用幻灯片的索引指定要合并的幻灯片。以下是执行此操作的步骤。

  • 使用Presentation类加载目标演示。
  • 使用Presentation类加载源演示文稿。
  • 使用presentation1.Slides.AddClone(presentation2.Slides [int Index])方法克隆所需的幻灯片。
  • 将合并的演示文稿另存为新的PPTX文件。

下面的代码示例演示如何使用C#合并演示文稿的特定幻灯片。

// Instantiate a Presentation object that represents a target presentation fileusing (Presentation presentation1 = new Presentation("presentation1.pptx")){  // Instantiate a Presentation object that represents a source presentation fileusing (Presentation presentation2 = new Presentation("presentation2.pptx")){// Merge only even slides of presentation2 (first slide is at 0 index)for (int i = 1; i <= presentation2.Slides.Count; i = i + 2) { presentation1.Slides.AddClone(presentation2.Slides[i]); } } presentation1.Save("merged-presentation-even.pptx", Export.SaveFormat.Pptx); }

合并简

PPT处理控件Aspose.Slides功能演示:使用C#或VB.NET合并PowerPoint演示文稿

合并PowerPoint演示文稿时使用幻灯片母版

在某些情况下,您可能需要根据目标演示文稿来修改幻灯片的布局。在这种情况下,可以使用重载的presentation1.Slides.AddClone(presentation2.Slides [1],presentation1.Masters [0],true)方法。

下面的代码示例演示如何使用C#中的幻灯片母版在PowerPoint演示文稿中合并幻灯片。

// Instantiate a Presentation object that represents a target presentation fileusing (Presentation presentation1 = new Presentation("presentation1.pptx")){  // Instantiate a Presentation object that represents a source presentation fileusing (Presentation presentation2 = new Presentation("presentation2.pptx")){// Merge first two slides only using slide masterpresentation1.Slides.AddClone(presentation2.Slides[0], presentation1.Masters[0], true);presentation1.Slides.AddClone(presentation2.Slides[1], presentation1.Masters[0], true);}presentation1.Save("merged-presentation-master.pptx", Export.SaveFormat.Pptx);}

合并简

PPT处理控件Aspose.Slides功能演示:使用C#或VB.NET合并PowerPoint演示文稿


还想要更多吗可以点击阅读【2019 · Aspose最新资源整合】查找需要的教程资源。如果您有任何疑问或需求,请随时加入Aspose技术交流群(),我们很高兴为您提供查询和咨询
标签:

声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2020年7月15日
下一篇 2020年7月15日

相关推荐

发表回复

登录后才能评论