ReportUtil 1.0.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package ReportUtil --version 1.0.2
                    
NuGet\Install-Package ReportUtil -Version 1.0.2
                    
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="ReportUtil" Version="1.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ReportUtil" Version="1.0.2" />
                    
Directory.Packages.props
<PackageReference Include="ReportUtil" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ReportUtil --version 1.0.2
                    
#r "nuget: ReportUtil, 1.0.2"
                    
#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.
#:package ReportUtil@1.0.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ReportUtil&version=1.0.2
                    
Install as a Cake Addin
#tool nuget:?package=ReportUtil&version=1.0.2
                    
Install as a Cake Tool

ReportUtil

A .net core utility library to export generic lists to excel file using Open Xml SDK. The collections could be master-detail style, and the cells for master fields could be merged.

Nuget package is available here.

The result snapshot looks like as following.

alternate text is missing from this package README image

How to use

  1. Install the library from Nuget
> Install-Package ReportUtil -Version 1.0.1
  1. Suppose we have following model
public class Category
    {
        public string Code { get; set; }
        public string Name { get; set; }

        public List<Product> Products { get; set; }
    }


public class Product
    {
        public int ProductId { get; set; }
        public string Name { get; set; }

        public string Desctiption { get; set; }

        public decimal Price { get; set; }

        public DateTime CreateDate { get; set; }

    }
    

and We have a collection of Category.

2.1 Firstly, define the ColumnDef array,

var columnDefs = new ColumnDefBase[]
                        {
                            new ColumnDef<Category>()
                            {
                                 Captain="CategoryCode",
                                 TargetDataType=new  EnumValue<CellValues>(CellValues.String),
                                 GetValueFunc=(o)=>new  CellValue(o.Code)
                            },
                            new ColumnDef<Category>()
                            {
                                 Captain="CategoryName",
                                 TargetDataType=new  EnumValue<CellValues>(CellValues.String),
                                 GetValueFunc=(o)=>new  CellValue(o.Name)
                            },
                            new ColumnDef<Product>()
                            {
                                 Captain="ProductId",
                                 TargetDataType=new  EnumValue<CellValues>(CellValues.String),
                                 GetValueFunc=(o)=>new  CellValue(o.ProductId.ToString())
                            },
                            
                            ...//ommit some code for simplicity
                            new ColumnDef<Product>()
                            {
                                Captain="CreateDate",
                                TargetDataType=new  EnumValue<CellValues>(CellValues.Date),
                                GetValueFunc=(o)=>new  CellValue(o.CreateDate.ToString("s"))
                            }
                        };
                            

2.2 If we have already a template xlsx file to define the captain rows and read it into stream, call the function like following,

new ReportHelper().GenerateReportWithTemplate<Category, Product>(stream,data, columnDefs, (o) => o.Products);

2.3 If there's no template file, just call another function ,

var stream = new ReportHelper().GenerateReport<Category, Product>(data, columnDefs, (o) => o.Products);

2.4 Save the stream to file or a http response output stream, you will get an excel report file.

Enjoy it!

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.2 is compatible.  netcoreapp3.0 was computed.  netcoreapp3.1 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.0.9 665 12/5/2019
1.0.8 555 12/4/2019
1.0.7 588 12/3/2019
1.0.6 563 12/3/2019
1.0.5 659 11/3/2019
1.0.4 610 11/1/2019
1.0.3 583 11/1/2019
1.0.2 566 11/1/2019
1.0.1 590 10/31/2019
1.0.0 782 10/31/2019 1.0.0 is deprecated because it is no longer maintained.
1.0.0-CI-20191101-070123 428 11/1/2019
1.0.0-CI-20191101-070113 432 11/1/2019