Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when using RepeatContent #73

Open
ashadu21 opened this issue Jun 5, 2024 · 1 comment
Open

Error when using RepeatContent #73

ashadu21 opened this issue Jun 5, 2024 · 1 comment

Comments

@ashadu21
Copy link

ashadu21 commented Jun 5, 2024

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.

@GoldSucc
Copy link

GoldSucc commented Jul 7, 2024

You can use Table content instead, it works fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants