Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

145
Views
Insertar fila al final de un excel C# .NET

¡Buenos días a todos!

Estoy tratando de agregar una nueva fila a un Excel al final de todos los datos.

Como puede ver, el Excel tiene un encabezado y luego todos los registros del "billingSummary". Al final de este último, me gustaría agregar una fila para calcular los totales.

 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;

¡Espero que puedas ayudarme! ¡Gracias!

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Con respecto al código que ha comentado al poner un nuevo valor a excelDataRows es resetear el valor de la lista, lo que hay que usar es el método Add que tiene la lista.

Aquí te dejo un ejemplo de cómo debes hacerlo en base al código que has comentado.

 excelDataRows.Add(new ExcelDataTableRow { CellValues = new List<string> { "HOLA", "CHAU" } } ); return excelDataRows;
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!