Answers for "object to excel c#"

C#
0

object to excel c#

maybe you could try use Infodinamica.Framework.Expotable package, hosted in Nuget.

With it, you could do something like this

List<EmployeeData> query = data.Where(x => x.Field<string>("First_Name") != string.Empty).Select(x =>

    new EmployeeData
        {
        empID = x.Field<double>("EMPLOYEE"),
        firstName = x.Field<string>("First_Name"),
        lastName = x.Field<string>("Last_Name"),
        JobCategory = x.Field<string>("Job Title"),
        StartDate = x.Field<Nullable<DateTime>>("Hire Dt"),
        EndDate =   x.Field<Nullable<DateTime>>("Term Dt"),
        TermReason = x.Field<string>("Term Reason"),
        PeggedUID = x.Field<Nullable<double>>("Pegged UserID"),
        UpdateDate = x.Field<Nullable<DateTime>>("Last Updated")
        }).ToList();

    IExportEngine engine = new ExcelExportEngine();
    engine.AddData(EmployeeData);
    MemoryStream memory = engine.Export();
You can install with nuget command:

Install-Package Infodinamica.Framework.Exportable
The only problem, documentation is in spanish.

The project page is here

Export example (in spanish) is here

It also enable import files (in spanish) here
Posted by: Guest on March-17-2021

C# Answers by Framework

Browse Popular Code Answers by Language