We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

How to import data from dynamic collection using XlsIO?

This article explains how to import data from a dynamic collection in XlsIO using C#/VB.NET

 

How to import dynamic collection?

 

XlsIO provides the support to import data into a worksheet from data table, array and business objects.The data source can be a dynamic object collection.

 

To import data from a dynamic collection, you need to follow the below steps.

Steps to import dynamic collection:

1. To import data using dynamic object list, the dynamic object should override three methods from System.Dynamic.DynamicObject which are,

 

  • TryGetMember(GetMemberBinder binder, out object result),
  • TrySetMember(SetMemberBinder binder, object value) and
  • GetDynamicMemberNames().

 

2. To get the value for a member, the TryGetMember (GetMemberBinder binder, out object result) method is used.

 

3. To set the value for a member, the TrySetMember(SetMemberBinder binder, object value) is used.

 

4. To get the members from the dynamic object GetDynamicMemberNames() method is used.

 

5. Import the dynamic collection into worksheet.      

In this,GetMembersReport() method provides the dynamic collection to be imported into the worksheet. 

Note : If XlsIO can’t find these methods then it will not able to import the data in the worksheet which results in throwing an exception.

 

To know more about importing data from various sources using XlsIO, please refer the documentation.

 

Download Complete Sample

The following C#/VB.NET complete code snippet shows how to import data from a dynamic collection.

 

 

 

The below screenshot shows the output after the dynamic object data is imported into the excel file.

 

 

Article ID: Published Date: Last Revised Date: Platform: Control:
8538 02/28/2018 02/28/2018 Windows Forms XlsIO
Tags:
Did you find this information helpful?
Add Comment
You must log in to leave a comment

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.