【发布时间】:2021-11-19 07:29:14
【问题描述】:
在 aspnet 零 ExcelExporter 类中出现错误。 “无法从用法中推断出方法的类型参数。请尝试显式指定类型参数。”
NpoiExcelExporterBase.AddObjects(ISheet, IList, params Func
[])
public FileDto ExportToFile(List<GetProductForViewDto> products)
{
return CreateExcelPackage(
"Products.xlsx",
excelPackage =>
{
var sheet = excelPackage.CreateSheet(L("Products"));
AddHeader(
sheet,
L("Model"),
L("PartNo"),
L("Description"),
L("UnitOfMeasure"),
L("Barcode"),
(L("Category")) + L("Description"),
(L("Brand")) + L("Description")
);
AddObjects(
sheet, 2, products,
_ => _.Product.Model,
_ => _.Product.PartNo,
_ => _.Product.Description,
_ => _.Product.UnitOfMeasure,
_ => _.Product.Barcode,
_ => _.CategoryDescription,
_ => _.BrandDescription
);
});
}
任何人都可以帮助为什么会发生这种情况。我想我错过了 AddObjects 参数中的某些内容。
谢谢
【问题讨论】:
-
2 有什么用?它似乎不适合方法签名
-
让我检查一下,我认为这可能是原因