将演示文稿合并为单个演示文稿

编程入门 行业动态 更新时间:2024-10-11 07:31:59
本文介绍了将演示文稿合并为单个演示文稿的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用 GemBox.Presentation,我需要合并多个 PPTX 文件,将它们组合成单个 PPTX 文件.

I'm using GemBox.Presentation and I need to merge multiple PPTX files, combine them into a single PPTX file.

我试过了:

PresentationDocument presentation1 = PresentationDocument.Load("PowerPoint1.pptx"); PresentationDocument presentation2 = PresentationDocument.Load("PowerPoint2.pptx"); foreach (Slide slide2 in presentation2.Slides) presentation1.Slides.Add(slide2);

但我收到以下错误:

项目已包含在某个集合中.首先将其从该集合中删除.参数名称:item

Item is already contained in some collection. Remove it from that collection first. Parameter name: item

如何将多个演示文稿合并为一个演示文稿?

How can I merge several presentations into one presentation?

推荐答案

使用 AddCopy 方法而不是 Add.换句话说,试试这个:

Use one of the AddCopy methods instead of Add. In other words, try this:

var presentation1 = PresentationDocument.Load("PowerPoint1.pptx"); var presentation2 = PresentationDocument.Load("PowerPoint2.pptx"); // Merge "PowerPoint2.pptx" file into "PowerPoint1.pptx" file. var context = CloneContext.Create(presentation2, presentation1); foreach (var slide in presentation2.Slides) presentation1.Slides.AddClone(slide, context); // Save resulting "Merged PowerPoints.pptx" file. presentation1.Save("Merged PowerPoints.pptx");

另外,您可以参考克隆示例.

Also, you can refer to Cloning example.

更多推荐

将演示文稿合并为单个演示文稿

本文发布于:2023-10-31 10:43:19,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1545843.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:演示文稿   并为

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!