Aspose Words Linq Report Nested Table

Hi,

I’m evaluating Aspose. I have a requirement that generate Word with a part will be displayed as Tree View like below:

  1. ABC
    1.1 BCD
    1.1.1 DEF
    1.1.1.1 GEF
    1.2 EFC
  2. DBCD
    2.1 ASASDAsd
  3. DSFD

    However, I don’t know how many level will be shown by default (can be 1 or 10 level). It will be loaded from DB. I tried with LINQ but can’t find an example to solve it.

I don’t want to use HTML for this case because it will dirty code with mixing between doc template and HTML stuff (style, padding, margin…).

Note: Every level will be padded a small gap deeper from its parent.

Is it possible to reach that target with Aspose template syntax (recursive or nested call…)?

Thanks,
Tu

@tranquoctu1988,

Thanks for your inquiry. In your case, we suggest you please create the LINQ template that contains list with conditional block. In Word documents, lists consist of 1 to 9 levels. Please read the following articles. Hope this helps you.

Multicolored Numbered List Template
Using Conditional Blocks

Could you please share the structure of your database table or data source in the form XML here for our reference? We will then provide you more information about your query.

Thank for your quick response. The XML structure will be like this:

<list>
<point>
<num>1<is /num>
<paragraph>lorem ipsum</paragraph>
</point>
<point>
<num>2</num>
<paragraph>lorem ipsum</paragraph>
<list>
<point>
<num>2.1</num>
<paragraph>lorem ipsum</paragraph>
</point>
…
</list>
</point>
</list>

I read your suggestion article about bullet, that’s seem I have to define exactly nested bullet level.
E.g

<<foreach [lv1 in ds]>>

1. <<[paragraph]>><<foreach [lv2 in lv1.list]>>
   1.1. <<[paragraph]>><</foreach>>
   <</foreach>>

Is it right? But in my case, the numeric is provided by data via so hardcode bullet or numeric in template will not word.
Thanks and Best Regards,
Tu

@tranquoctu1988,

Thanks for your inquiry. Yes, you can use the shared approach to get the desired output.

Please manually create your expected output Word document using Microsoft Word and attach it here for our reference. We will investigate how you want your final Word output be generated like. Please also share the XML data source. We will then provide you more information on this along with code.

Hi,

I attached example data source (source.xml.pdf) and expected results (expected_output.docx.pdf). Please remove the “.pdf” for the original file.

Thanks and Best Regards,
Tu
expected_output.docx.pdf (14.9 KB)
source.xml.pdf (5.3 KB)

@tranquoctu1988,

Thanks for sharing the detail. In your case, we suggest you please create the template document as shown below. We have attached the input document and XML with this post for your kind reference. You can use the same approach to get the desired output. Docs.zip (10.2 KB)

<<foreach [lv1 in ds.point]>>
<<[lv1.num]>> <<[lv1.paragraph.content.p]>>
<<foreach [lv2 in lv1.listLevel1]>>
<<[lv2.num]>> <<[lv2.paragraph.content.p]>>
<<foreach [lv3 in lv2.listLevel2]>>
<<[lv3.num]>> <<[lv3.paragraph.content.p]>>
<</foreach>>
<</foreach>>
<</foreach>>
DataSet ds = new DataSet();
ds.ReadXml(MyDir + "source.xml");

Document doc = new Document(MyDir + "inputLinq.docx");
// Create a Reporting Engine.
ReportingEngine engine = new ReportingEngine();

engine.BuildReport(doc, ds, "ds");
doc.Save(MyDir + "17.7.docx");

Hi,

It’s worked but contains a lot of empty lines between paragraph.

Will it have any option to clean up the empty paragraph like Mail Merge(Remove Empty Paragraphs, Regions or Fields in Mail Merge | C# or Java) ?

Thanks and Best Regards,
Tu

@tranquoctu1988,

Thanks for your inquiry. Please check the attached modified template document to fix empty lines issue. inputLinq.zip (9.6 KB)