I have a dictionary, the key is a string, the value is a list of string. I want to write it into Excel using the ClosedXML library.
Dictionary<string, List<string>> data = new Dictionary<string, List<string>>();
List<string> list1 = new List<string>();
List<string> list2 = new List<string>();
List<string> list3 = new List<string>();
List<string> list4 = new List<string>();
list1.Add("a1","b1","c1");
list2.Add("a2","b2","c2");
list3.Add("a3","b3","c3");
list4.Add("a4","b4","c4");
data.Add("head1", list1);
data.Add("head2", list2);
data.Add("head3", list3);
data.Add("head4", list4);
So you see the keys are "head1","head2","head3","head4". The expected result in the excel cells should like
head1 head2 head3 head4
a1 a2 a3 a4
b1 b2 b3 b4
c1 c2 c3 c4
If I follow this link closedXml, ws.Cell(1,1).Value = "Hello World!";
is not working at all. It seems the Cell's arguments only accept bool value rather than int. I mean that the example in the link maybe wrong.
Is there a better way to finish the task in C#?