MH.Excel.Export 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package MH.Excel.Export --version 1.0.0                
NuGet\Install-Package MH.Excel.Export -Version 1.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MH.Excel.Export" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MH.Excel.Export --version 1.0.0                
#r "nuget: MH.Excel.Export, 1.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install MH.Excel.Export as a Cake Addin
#addin nuget:?package=MH.Excel.Export&version=1.0.0

// Install MH.Excel.Export as a Cake Tool
#tool nuget:?package=MH.Excel.Export&version=1.0.0                

MH.Excel.Export

MH.Excel.Export is a Excel (.xlsx) generator for ASP.NET Core applications.

Install via NuGet

To install MH.Excel.Export, run the following command in the Package Manager Console:

PM> Install-Package MH.Excel.Export

You can also view the package page on NuGet.

Usage:

After installing the MH.Excel.Export package, you can send any classes with (or without) [Display(Name ="")] attribute and get required data for pass to return File();

dntcaptcha

public class HomeController : Controller
{
    public async Task<IActionResult> Index()
    {
        var list = new TestClass().GetList();

        var excel = await ExportManager.ExportToXlsxAsync<TestClass, TestClass.SubClassTest>(list, "Test Excel Class");

        return File(excel.FileContents, excel.ContentType, excel.FileDownloadName);
    }
}

public class TestClass
{
    [Display(Name = "Id")]
    public int Id { get; set; }

    [Display(Name = "First Name")]
    public string Name { get; set; }

    [Display(Name = "Last Name")]
    public string Name2 { get; set; }


    [Display(Name = "Items")]
    public List<SubClassTest> List { get; set; } = new();


    public List<TestClass> GetList()
    {
        var tests = new List<TestClass>();

        for (int i = 1; i < 10; i++)
        {
            var test = new TestClass
            {
                Id = i,
                Name = $"Name - {i}",
                Name2 = $"Name2 - {i}",
            };

            for (int j = 1; j < 10; j++)
            {
                test.List.Add(new SubClassTest
                {
                    Id = 50 * j,
                    Type = $"Type - {j}",
                    Type2 = $"Type2 - {j}",
                    Type3 = $"Type3 - {j}"
                });
            }

            tests.Add(test);
        }

        return tests;
    }

    public class SubClassTest
    {
        [Display(Name = "Id")]
        public int Id { get; set; }

        [Display(Name = "attr1")]
        public string Type { get; set; }

        [Display(Name = "attr2")]
        public string Type2 { get; set; }

        [Display(Name = "attr3")]
        public string Type3 { get; set; }
    }
}
Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.8.0 242 12/4/2023
1.7.0 205 3/27/2023
1.5.0 444 5/4/2022
1.4.0 387 8/2/2021
1.3.0 336 8/2/2021
1.2.0 291 8/2/2021
1.1.0 327 8/1/2021
1.0.0 375 8/1/2021