3

以下のコードを使用して、1 つの段落の 2 つのランに 2 つの異なる文字スタイルを適用しました。

            Paragraph heading = new Paragraph();
            ParagraphProperties heading_pPr = new ParagraphProperties();
            heading.Append(heading_pPr);

            Run Run1 = new Run() { RsidRunProperties = "009531B2" };
            Text Text_Run1 = new Text("THIS IS TEST RUN 1");
            Run1.Append(Text_Run1);
            RunProperties rpr_Run1 = new RunProperties();
            rpr_Run1.RunStyle = new RunStyle() { Val = "CharacterStyle1" };

            Run Run2 = new Run();
            RunProperties rpr_Run2 = new RunProperties();
            rpr_Run2.RunStyle = new RunStyle() { Val = "CharacterStyle2" };
            Text text_Run2 = new Text("THIS IS TEST RUN 2");
            Run2.Append(text_Run2);

            heading.Append(Run1);
            heading.Append(Run2);
            body.Append(heading);

しかし、コードを実行した後、Word ファイルでは、これらの実行は通常のスタイルを取得します。段落スタイルを段落に適用できますが、実行する文字スタイルを適用できません。コードのどこが間違っていますか?

結論は:

実行に文字スタイルを適用する方法と、異なるスタイルの実行を持つ段落を作成する方法を教えてください。

4

1 に答える 1