PavelS0 / docx_template_dart

A Docx template engine
Apache License 2.0
40 stars 20 forks source link

How to add TextContent dynamically #7

Closed briceAlex closed 3 years ago

briceAlex commented 3 years ago

Hi,

I try to create a document like this dynamically :

Title : // dynamically

Thank you for you work on this package !

briceAlex commented 3 years ago

I started with that : ` Content c = Content();

            c
              ..add(TextContent("docname", "Simple test"))
              ..add(ListContent("Taches", [
                TextContent("value", "Taches").add(ListContent(
                    "listnested", [
                  for (var i = 0; i < 10; i++)
                    TextContent("value", " i : ${i}")
                ]))
              ]));

`

PavelS0 commented 3 years ago

hi, like this:

Content c = Content();

final list = <Content>[];
for (var i = 0; i < 10; i++) 
   list.add(TextContent("value", " i : ${i}"));

c
  ..add(TextContent("docname", "Simple test"))
  ..add(ListContent("Taches", list));
briceAlex commented 3 years ago

Hi, all works well thanks to you !