Skip to content

Error when using RepeatContent  #73

@ashadu21

Description

@ashadu21

Scenario -
I have a document template with few fields lets say USERNAME, AGE, SEX and ADDRESS in a table. All these fields are setup as "Plain Text Content Control". This table row along will all these fields are setup as "Repeating Section Content Control" as shown below.

image

Question -
How do I repeat the table row and populate these fields for various USESRNAME. I have written the below code.

File.Copy(Repeater, RepeaterResult);

var repeatertoFill = new Content(new RepeatContent("Repeater2")
    .AddItem(
        new FieldContent("NAME1", "Smith"),
        new FieldContent("AGE1", "50"),
        new FieldContent("SEX1", "M"),
        new FieldContent("ADDRESS1", "Address Smith"))
    .AddItem(
        new FieldContent("NAME1", "Mary"),
        new FieldContent("AGE1", "50"),
        new FieldContent("SEX1", "F"),
        new FieldContent("ADDRESS1", "Address Mary"))
    .AddItem(
        new FieldContent("NAME1", "David"),
        new FieldContent("AGE1", "50"),
        new FieldContent("SEX1", "M"),
        new FieldContent("ADDRESS1", "Address David"))

using (var outputDocument = new TemplateProcessor(RepeaterResult))
{
    outputDocument.FillContent(repeatertoFill);
    outputDocument.SaveChanges();
}

However, I get this error "Field content for field '' not found".

I would like my final word file to look something like this..

image

I am new to this package and hence any insights to use RepeatContent on a table is appreciated.

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