You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using XL Mapper version 5.2.352 with .Net core 5.
Since my data structure can contain varying number of columns I have those data arranged in a collection of dictionaries. A dictionary has data similar to below;
I assume the Keys of the dictionary will be taken as column headings and the values of each dictionary will be written as rows in the XL.
var mylist = new List<IDictionary<string, string>>();
//fill data to a new dictionary instance
var itemdict = new Dictionary.....
mylist.Add(itemdict);
....
xlMapper.Save(fileName, mylist);
When I do this as above it throws below exception;
System.Reflection.TargetParameterCountException: Parameter count mismatch.
at System.Reflection.RuntimeMethodInfo.InvokeArgumentsCheck(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.RuntimePropertyInfo.GetValue(Object obj, Object[] index)
at Ganss.Excel.ColumnInfo.GetProperty(Object o)
at Ganss.Excel.ExcelMapper.SetCell[T](Func3 valueConverter, T objInstance, ICell cell, ColumnInfo ci) at Ganss.Excel.ExcelMapper.SetCells(TypeMapper typeMapper, Dictionary2 columnsByIndex, Object o, IRow row, Func3 valueConverter) at Ganss.Excel.ExcelMapper.Save[T](Stream stream, ISheet sheet, IEnumerable1 objects, Func3 valueConverter) at Ganss.Excel.ExcelMapper.Save[T](Stream stream, IEnumerable1 objects, Int32 sheetIndex, Boolean xlsx, Func3 valueConverter) at Ganss.Excel.ExcelMapper.Save[T](String file, IEnumerable1 objects, Int32 sheetIndex, Boolean xlsx, Func`3 valueConverter)
However if I change my code to;
var mylist = new List<dynamic>(); //earlier it was of type IDictionary<string, string>
//fill data to a new dictionary instance
var itemdict = new Dictionary.....
mylist.Add(itemdict);
....
xlMapper.Save(fileName, mylist);
Now it doesn't throw an exception, but nothing gets written to the file.
How can I get this done properly?
The text was updated successfully, but these errors were encountered:
This use case isn't currently supported. The closest is support for dynamic objects so you could pass a list of ExpandoObject (which implements IDictionary<string, object>) to Save(). Still this necessitates that each object in the list has all keys, possibly with null values for the unused columns.
I am using XL Mapper version 5.2.352 with .Net core 5.
Since my data structure can contain varying number of columns I have those data arranged in a collection of dictionaries. A dictionary has data similar to below;
I assume the Keys of the dictionary will be taken as column headings and the values of each dictionary will be written as rows in the XL.
When I do this as above it throws below exception;
System.Reflection.TargetParameterCountException
Parameter count mismatch.
System.Reflection.TargetParameterCountException: Parameter count mismatch.
at System.Reflection.RuntimeMethodInfo.InvokeArgumentsCheck(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.RuntimePropertyInfo.GetValue(Object obj, Object[] index)
at Ganss.Excel.ColumnInfo.GetProperty(Object o)
at Ganss.Excel.ExcelMapper.SetCell[T](Func
3 valueConverter, T objInstance, ICell cell, ColumnInfo ci) at Ganss.Excel.ExcelMapper.SetCells(TypeMapper typeMapper, Dictionary
2 columnsByIndex, Object o, IRow row, Func3 valueConverter) at Ganss.Excel.ExcelMapper.Save[T](Stream stream, ISheet sheet, IEnumerable
1 objects, Func3 valueConverter) at Ganss.Excel.ExcelMapper.Save[T](Stream stream, IEnumerable
1 objects, Int32 sheetIndex, Boolean xlsx, Func3 valueConverter) at Ganss.Excel.ExcelMapper.Save[T](String file, IEnumerable
1 objects, Int32 sheetIndex, Boolean xlsx, Func`3 valueConverter)However if I change my code to;
Now it doesn't throw an exception, but nothing gets written to the file.
How can I get this done properly?
The text was updated successfully, but these errors were encountered: