翻譯|使用教程|編輯:李顯亮|2020-08-18 10:51:59.600|閱讀 621 次
概述:合并PowerPoint演示文稿在各種情況下很有用,例如合并來自多個PPT / PPTX的內容,合并由兩個或更多人創建的單個演示文稿的各個部分等。本文講解.NET開發人員學習如何使用C#以編程方式合并PowerPoint演示文稿。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
合并PowerPoint演示文稿在各種情況下很有用,例如合并來自多個PPT / PPTX的內容,合并由兩個或更多人創建的單個演示文稿的各個部分等。
在處理時,手動復制/粘貼內容的方式可能不適合有很多演示文稿。因此,本文使.NET開發人員可以學習如何使用C#以編程方式合并PowerPoint演示文稿。很高興的是,Aspose.Slides已經迎來2020年8月更新,增強了多項功能,如果你還沒有升級Aspose.Slides最新版測試,可以點擊這里下載。
在本節中,將學習如何將所有幻燈片從一個PowerPoint演示文稿克隆和合并到另一幻燈片。為此,可以簡單地從源演示文稿中克隆幻燈片并將其添加到目標演示文稿的末尾。以下是合并兩個演示文稿的步驟。
下面的代碼示例演示如何使用C#合并兩個PowerPoint演示文稿。
// Instantiate a Presentation object that represents a target presentation file using (Presentation presentation1 = new Presentation("presentation1.pptx")) { // Instantiate a Presentation object that represents a source presentation file using (Presentation presentation2 = new Presentation("presentation2.pptx")) { foreach (ISlide slide in presentation2.Slides) { // Merge slides from source to target presentation1.Slides.AddClone(slide); } } // Save the presentation presentation1.Save("merged-presentation.pptx", Export.SaveFormat.Pptx); }
目標介紹
來源介紹
合并簡報
在某些情況下,只需要合并選定的幻燈片即可。在這種情況下,可以使用幻燈片的索引指定要合并的幻燈片。以下是執行此操作的步驟。
下面的代碼示例演示如何使用C#合并演示文稿的特定幻燈片。
// Instantiate a Presentation object that represents a target presentation file using (Presentation presentation1 = new Presentation("presentation1.pptx")) { // Instantiate a Presentation object that represents a source presentation file using (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); }
合并簡報
在某些情況下,您可能需要根據目標演示文稿來修改幻燈片的布局。在這種情況下,可以使用重載的presentation1.Slides.AddClone(presentation2.Slides [1],presentation1.Masters [0],true)方法。
下面的代碼示例演示如何使用C#中的幻燈片母版在PowerPoint演示文稿中合并幻燈片。
// Instantiate a Presentation object that represents a target presentation file using (Presentation presentation1 = new Presentation("presentation1.pptx")) { // Instantiate a Presentation object that represents a source presentation file using (Presentation presentation2 = new Presentation("presentation2.pptx")) { // Merge first two slides only using slide master presentation1.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); }
合并簡報
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn