Main Content

プレゼンテーション書式の継承

PPT API では、PowerPoint® テンプレートと、PPT API の書式オブジェクトおよび書式プロパティを使用して、プレゼンテーション オブジェクトを書式設定できます。書式設定の方法を組み合わせることができます。

PowerPoint テンプレートで指定する書式設定によって、プレゼンテーション コンテンツの既定の書式が指定されます。

PPT API を使用して、特定のプレゼンテーション オブジェクトを書式設定できます。次が可能です。

  • プレゼンテーション オブジェクトの Style プロパティで使用できる書式オブジェクトを定義

  • プレゼンテーション オブジェクトの書式プロパティの値を指定

Style プロパティによる書式設定と、書式プロパティによる書式設定を組み合わせることができます。例:

p = Paragraph('This is a paragraph');
p.Style = {Bold(true),Underline('wavy')};
p.FontColor = 'red';

各方法を使用して同じ書式設定の特性を定義する場合、PPT API はコード内で後に出現する方の指定を使用します。たとえば、次のコードは段落のテキストの既定の色として青を指定します。

p = Paragraph('This is a paragraph');
p.Style = {FontColor('red')};
p.FontColor = 'blue';

いくつかの PPT API オブジェクトは階層的です。例:

  • Text オブジェクトを Paragraph オブジェクトに追加できる。

  • TableEntry オブジェクトを TableRow に追加し、TableRow オブジェクトを Table に追加できる。

親オブジェクトの書式設定がその子オブジェクトに適用されます。ただし、子オブジェクトで指定された書式は、親の書式設定をオーバーライドします。例:

import mlreportgen.ppt.*;

ppt = Presentation('myParagraphPresentation.pptx');
open(ppt);

slide1 = add(ppt,'Title and Content');

%% Use Unicode for special characters
p = Paragraph('Parent default red text: ');
p.FontColor = 'red';

t = Text('child text object blue text');
t.FontColor = 'blue';

append(p,t);
add(slide1,'Content',p);

close(ppt);
rptview(ppt);

Bulleted list item with a red bullet and red text "Parent default red text, followed by blue text "child text object blue text"