【发布时间】:2020-04-27 15:28:03
【问题描述】:
已经接管了一个使用 ClosedXML 的遗留项目。创建错误的方法需要一个
IEnumerable<MainObject> rows
并创建一个工作表。但是存在另一个属性
IEnumerable<Object1>
在主对象中。代码通过
执行 worksheet.Cell(startRow, 1).InsertTable(rows);
当我这样做时,我得到了
An unhandled exception has occurred: Unable to set cell value to System.Collections.Generic.List`1[Object1]
System.ArgumentException: Unable to set cell value to System.Collections.Generic.List`1[Object1]
我的猜测是我必须创建另一个(被覆盖?)InsertTable,它使用反射来调用正确的类型,然后甚至在 IEnumerable 属性上使用 InsertTable。 但是有可能在重写的函数中使用某种递归调用并跳过所有自定义映射吗?
任何想法或建议都会很好。
【问题讨论】:
标签: c# generic-list closedxml