We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to reference fields in DataTables within DataSet

I have a business case where I have a generic Letter template, in which I insert a building block Word document for the content.
I have generic data (Addressee, Date, Reference etc) and custom data, depending on the building block that is inserted.
I have created a DataSet named ‘ds’ with two tables ‘Generic’ and ‘Specific’, each with one row.
To use ReportingEngine, do I need to pass the dataSourceName parameter to BuildReport, and what is the syntax for the expression in my tags? (I tried things like << [ds.Generic.Rows[0].Name] >> and several other variations.

Best regards,

@TimDol You can use First() or FirstOrDefault() to access the first row of the DataTable. For example see the following simple code:

DataSet ds = new DataSet("ds");
DataTable generic = new DataTable("Generic");
generic.Rows.Add(new string[] { "Alexey", "Noskov" });


Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

ReportingEngine engine = new ReportingEngine();
engine.BuildReport(doc, ds, "ds");
1 Like