ForEach

ForEach 类

表示一组旨在遍历不同 Presentation 模型对象的方法。如果您需要遍历并更改某些 Presentation 元素的格式或内容,例如更改每个部分的格式,这些方法会很有用。

public static class ForEach

方法

名称描述
static LayoutSlide(Presentation, ForEachLayoutSlideCallback)遍历 Presentation 中的每个 LayoutSlide
static MasterSlide(Presentation, ForEachMasterSlideCallback)遍历 Presentation 中的每个 MasterSlide
static Paragraph(Presentation, ForEachParagraphCallback)遍历 Presentation 中的每个 Paragraph。形状将在所有类型的幻灯片中进行迭代 - SlideMasterSlideLayoutSlide
static Paragraph(Presentation, bool, ForEachParagraphCallback)遍历 Presentation 中的每个 Paragraph。形状将在所有类型的幻灯片中进行迭代 - SlideMasterSlideLayoutSlideNotesSlide
static Portion(Presentation, ForEachPortionCallback)遍历 Presentation 中的每个 Portion。部分将在所有类型的幻灯片中进行迭代 - SlideMasterSlideLayoutSlide
static Portion(Presentation, bool, ForEachPortionCallback)遍历 Presentation 中的每个 Portion。部分将在所有类型的幻灯片中进行迭代 - SlideMasterSlideLayoutSlideNotesSlide
static Shape(BaseSlide, ForEachShapeCallback)遍历 BaseSlide 中的每个 ShapeBaseSlideSlideMasterSlideLayoutSlide 的基类型。
static Shape(Presentation, ForEachShapeCallback)遍历 Presentation 中的每个 Shape。形状将在所有类型的幻灯片中进行迭代 - SlideMasterSlideLayoutSlide
static Shape(Presentation, bool, ForEachShapeCallback)遍历 Presentation 中的每个 Shape。形状将在所有类型的幻灯片中进行迭代 - SlideMasterSlideLayoutSlideNotesSlide(如有需要)。
static Slide(Presentation, ForEachSlideCallback)遍历 Presentation 中的每个 Slide

其他成员

名称描述
delegate ForEachLayoutSlideCallback将在 Presentation 中的每个 LayoutSlide 调用的回调。
delegate ForEachMasterSlideCallback将在 Presentation 中的每个 MasterSlide 调用的回调。
delegate ForEachParagraphCallback将在 BaseSlide 上的每个 Paragraph 调用的回调。
delegate ForEachPortionCallback将在 BaseSlide 上的 Paragraph 中的每个 Portion 调用的回调。
delegate ForEachShapeCallback将在 Presentation 中的每个 Shape 调用的回调。
delegate ForEachSlideCallback将在 Presentation 中的每个 Slide 调用的回调。

示例

using (Presentation presentation = new Presentation("pres.pptx"))
{
   ForEach.Portion(presentation, (portion, para, slide, index) =>
   {
       portion.PortionFormat.LatinFont = new FontData("Times New Roman");
   });
  
   presentation.Save("pres-out.pptx", SaveFormat.Pptx);
}

另请参见