Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

139
Vistas
Insert row at the end of an excel C# .NET

Good morning everyone!

I am trying to add a new row to an excel at the end of all data.

As you can see, the excel has a header and then all the records from the "billingSummary". At the end of the latter, I would like to add a row to calculate the totals.

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;

I hope you can help me! Thank you!

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

With respect to the code that has commented when setting a new value to excelDataRows it is resetting the value of the list, what you have to use is the Add method that has the list.

Here I leave you an example of how you should do it based on the code that you have commented.

excelDataRows.Add(new ExcelDataTableRow
    {
        CellValues = new List<string>
        {
            "HOLA",
            "CHAU"
        }
    }
); 

return excelDataRows;
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda