6

3つのスライドを含むPowerpointプレゼンテーションがあります。各スライドには、プレースホルダーであるテキストボックスがあります。1つのスライドのテキストボックスの内容を置き換えたいのですが。

C#とOpenXMLを使用してこれを行う方法を知る必要があります

トンありがとう

4

1 に答える 1

3

変更するスライドごとにこれを行います。

ODP.ShapeTree tree = slide.Slide.CommonSlideData.ShapeTree;
        foreach (ODP.Shape shape in tree.Elements<ODP.Shape>())
        {
            // Run through all the paragraphs in the document
            foreach (ODD.Paragraph paragraph in shape.Descendants().OfType<ODD.Paragraph>())
            {
                foreach (ODD.Run run in paragraph.Elements<ODD.Run>())
                {
                    if (run.Text.InnerText.Contains("PLACEHOLDER"))
                    {
                        run.Text = new ODD.Text("Your new text");
                    }
                }
            }
        }

テンプレートのプレースホルダーにスペースが含まれている場合、2 つの個別の run 要素が作成される可能性があることに注意してください。そのため、「Place holder」の run.Text を持つ 1 つの run 要素の代わりに、「Place」の run.text を持つ 1 つの run と、run.Text 「holder」を持つ別の run を取得することができます。

于 2013-12-09T15:17:21.370 に答える