Skip to content

Error while hiding nested RepeatContent. #47

Open

Description

Exception locate is file RepeatProcessor.cs, line 105 (code: contentControl.DescendantsAndSelf(W.sdt).Remove();)

Error message: The parent is missing

Input file: InputTemplate.docx

Programm code:

using System.IO;
using TemplateEngine.Docx;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            File.Delete("OutputDocument.docx");
            File.Copy("InputTemplate.docx", "OutputDocument.docx");

            var valuesToFill = new Content(
                new RepeatContent("RepeatParentContent")
                    .AddItem(
                        new RepeatContent("RepeatChildrenContent").Hide()
                            .AddItem(new FieldContent("OrganizationName", "Рога и копыта")))
            );

            using (var outputDocument = new TemplateProcessor("OutputDocument.docx")
                .SetRemoveContentControls(true))
            {
                outputDocument.FillContent(valuesToFill);
                outputDocument.SaveChanges();
            }
        }
    }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions