I have a worker with various fields that are fetched from server. I am using CSVHelper package to convert this class to an excel sheet.
Worker has Fields like :
class Worker
{
string name;
string phone;
string age;
Dictionary<string,object> customerField;
}
I can map the name, phone, number like
class WorkerMap : CsvClassMap<Worker>
{
public WorkerMap()
{
Map(m => m.name);
Map(m => m.phone);
Map(m => m.age);
}
}
And I generate the map by :
csv.Configuration.RegisterClassMap<WorkerMap>();
Write the list of workers by :
csv.WriteRecords(workerList);
How can I map the customerField dictionary to the excel sheet such that the Key (string) is another column name and the value(object) is the value of the column.
Does CSVHelper help us do it at runtime. I looked through the documentation. Couldn't find anything that worked for me.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…