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

Free Support Forum - aspose.com

Generate report with dynamic data sources in LINQ Reporting using .NET

I have some multi-level data described by a JSON string which I’m deserializing into a dynamic object using


I was disappointed to discover that I can’t use this dynamic object as a data source for BuildReport(). I also tried deserializing into an Expando object, but that did not work either. I even tried reshaping the data into Dictionary<string,Object> containers… another failure.

I finally had success using a DataSet, but this breaks on some JSON fragments and also requires that the relationships are set up which is sometimes difficult to model without detailed knowledge of the ID fields in the JSON.

Is it correct that I need to use DataSet?

If so, then my request is that you consider supporting dynamic or Expando objects as data sources to BuildReport(). I certainly would appreciate it and I’m sure others would as well. It should not be difficult because such objects make it easy to enumerate properties and you’re already using reflection to find the properties of public types.


Hi Fred,

Thanks for your inquiry. It would be great if you please share following detail here for our reference. We will then provide you more information about your query.

  • Your template Word document.
  • Please share complete detail of your use case.
  • Please share JSON string that you are using as data source.
  • Please share the code example that you are using to build report using Linq reporting engine.

Thanks for your cooperation.

PS: To attach these resources, please zip them and Click 'Reply' button that will bring you to the 'reply page' and there at the bottom you can include any attachments with that post by clicking the 'Add/Update' button.

Hi Tahir,

Another recent problem caused me to revisit this issue and renew my request that you add support for using dynamic/expando objects as data sources for BuildReport(). From other threads, it appears to be already logged as WORDSNET-12148, but I thought I would go ahead and ask again.

The benefit to me and other customers is that C# now makes it very easy to construct dynamic objects either by hand or using a JSON deserializer and it would be super-convenient to be able to pass these objects directly to BuildReport().

I have attached a small sample program that demonstrates what I would like to be able to do.

Thanks for your consideration,


aspose_dynamic_data_source.zip (146.7 KB)


Thanks for sharing the detail. We have logged this feature request as WORDSNET-16017 in our issue tracking system. You will be notified via this forum thread once this feature is available.

We apologize for your inconvenience.


Further to my last post, we suggest you please use DataSet/DataTable/DataRow objects when dealing with data having dynamic structure. The DataSet class has built-in capabilities to read data from a database or XML file/stream.

Please note that LINQ Reporting Engine enables to use the same syntax for DataSet/DataTable/DataRow objects (including extension methods) as would be used with regular class instances thus making report templates almost the same in both cases. Please refer to the following article for more information.
Working with Traditional Mail Merge Data Sources

A post was split to a new topic: Use dynamic data source in Linq Reporting Engine using C#


Thanks for your patience.

Regarding support of dynamic data sources in LINQ Reporting, we have found a workaround involving recently introduced JsonDataSource and Newtonsoft Json.NET. Please check the following code snippet. Hope this helps you.

// Initialize a dynamic object.
dynamic sender = new ExpandoObject();
sender.Message = "Hello";

// Serialize the dynamic object to JSON.
string json = JsonConvert.SerializeObject(sender);

// Initialize a JSON data source.
MemoryStream jsonStream = new MemoryStream(Encoding.UTF8.GetBytes(json));
JsonDataSource dataSource = new JsonDataSource(jsonStream);

// Create a template document.
DocumentBuilder builder = new DocumentBuilder();

// Fill the template with data.
ReportingEngine engine = new ReportingEngine();
engine.BuildReport(builder.Document, dataSource);

// Print the result document.