Free Support Forum - aspose.com

Create Dynamic Table based on XML & Template Word Documents & Build Report using C# .NET

Hello Team,
I would like create a template with dynamic table based on the XML data. My scenario, I have an XML which holds dynamic table data that means the number of columns may differ for each case. I would like to create a generic template to create a table based on the XML data (Actual XML is attached). The attached XML contains the data from two tables (1. results table 2. RequestTest)

The structure of XML is as follows (Actual XML is attached)
MetaData node: It will hold the field names to display (like column headers)
<meta_data Table=“results” Field=“f_AeratedBulkDensitylbsft3” Label=“Aerated Bulk Density (lbs/ft3” />
Here,
Table -> Holds the reference node to check under Data node.
Field -> Mapping field name in the result node
Label -> Display value of field in the report. If not provided, field value should display in the report

Data node: It will hold the corresponding values/results for the fileds

Here,

results -> is the reference row defined in the meta data
f_AeratedBulkDensitylbsft3,f_PackedBulkDensitylbsft3, f_AeratedBulkDensitySG etc -> Mapping fields with values

Request you to help me on how to create a generic template for this scenario. The XML file and expected output report file (doc) is attached. Sample files.zip (33.1 KB)

@Shravan317,

We have logged your requirement in our issue tracking system. Your ticket number is WORDSNET-19810. We will further look into the details of this requirement and will keep you updated on the status of the linked issue. We apologize for any inconvenience.

@Shravan317,

Regarding WORDSNET-19810, we have completed the wok on this issue and concluded to close it as this neither a bug nor a new feature. You can meet this requirement by using various existing methods/APIs already available in Aspose.Words. For example, you may opt for adding TableStart:XXX and TableEnd:XXX region markers using DocumentBuilder based on your source XML data. You can also insert the tables with variable number of columns according with your needs. Or, since you want a dynamic output, maybe it is worth dropping the idea of using mail merge whatsoever in favor of building document content on the fly by using the document builder. We suggest you please refer to Aspose.Words’ documentation.