【发布时间】:2021-11-01 00:50:02
【问题描述】:
大家早上好!
我正在尝试在所有数据的末尾向 Excel 添加一个新行。
如您所见,excel 有一个标题,然后是“billingSummary”中的所有记录。在后者的末尾,我想添加一行来计算总数。
var excelDataRows = new List<ExcelDataTableRow>
{
new ExcelDataTableRow
{
CellValues = new List<string>
{
"Fecha",
"Contrato",
"Consorcio",
"Unidad",
"Importe Cobrado",
"Comisión Plataforma",
"Neto",
"Factura"
}
}
};
excelDataRows.AddRange(billingSummary.OrderBy(x => x.PaymentDate)
.ThenBy(x => x.OwnersAssociationCode)
.ThenBy(x => x.FunctionalUnitCode)
.Select(item => new ExcelDataTableRow
{
CellValues = new List<string>
{
item.PaymentDate.Day.ToString() + '/' + item.PaymentDate.Month.ToString() + '/' + item.PaymentDate.Year.ToString(),
item.ContractCode.ToString(),
item.OwnersAssociationCode.ToString(),
item.FunctionalUnitCode.ToString(),
item.TotalAmount.ToStringCurrency(),
item.PlapsaComission.ToStringCurrency(),
item.NetAmount.ToStringCurrency(),
item.Type + ' ' + item.PointOfSale + '-' + item.Number,
}
}));
//excelDataRows = new List<ExcelDataTableRow>
//{
// new ExcelDataTableRow
// {
// CellValues = new List<string>
// {
// "HOLA",
// "CHAU"
// }
// }
//};
return excelDataRows;
我希望你能帮助我!谢谢!
【问题讨论】:
-
你已经设定了一个目标——是什么阻止你完成它?您尝试过哪些尝试,哪些尝试没有奏效?
-
@mason 我尝试将它与您在此处看到的注释代码一起插入。但它不起作用,因为它重叠了该行的所有内容(“HOLA”和“CHAU”)
标签: c# .net excel asp.net-mvc linq