We are using Aspose.Cells for our export to excel requirements.There are different import object methods to write data in excel. Previously i was using following method where i had only one List object.
but now our requirement has been changed and we now creating dynamic class with dynamic properties and values. so now i have one dictionary object as follows.
var test = new Dictionary<string, List>();
In which keys are the header of the list and List is the values which should be write under that column.
so our test object will look like as follows.
test = {“Name”, [“asley”,“roger”,“test1”]}
{“Number”, [1,2,3]}
{“Date”, []}
{“Currency”, [10.5,11.2,20.3]}
So Can anyone help me in writing this dictionary object to excel? Is there any inbuilt method which aspose provides to write this? it would be appreciated if someone helps me to write this complex logic to export in excel
I am afraid, Aspose.Cells APIs do not provide direct means/methods to import Dictionary objects to worksheet cells. However, you can iterate over the Dictionary items and insert individual cell values as demonstrated below.
C#
var book = new Workbook();
var cells = book.Worksheets[0].Cells; int col = 0; int row = 0;
var dictionary = new Dictionary<string, List<object>>();
dictionary.Add(“Names”, new List<object> { “John”, “billy”, “Adam” });
dictionary.Add(“Dates”, new List<object> { DateTime.Parse(“2000-02-02”), DateTime.Parse(“2010-02-02”), DateTime.Parse(“2010-03-02”) });
dictionary.Add(“Numbers”, new List<object> { 12, 12, 13 });
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.