ReportUtil 1.0.1
See the version list below for details.
dotnet add package ReportUtil --version 1.0.1
NuGet\Install-Package ReportUtil -Version 1.0.1
<PackageReference Include="ReportUtil" Version="1.0.1" />
paket add ReportUtil --version 1.0.1
#r "nuget: ReportUtil, 1.0.1"
// Install ReportUtil as a Cake Addin
#addin nuget:?package=ReportUtil&version=1.0.1
// Install ReportUtil as a Cake Tool
#tool nuget:?package=ReportUtil&version=1.0.1
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.
How to use
- Install the library from Nuget
> Install-Package ReportUtil -Version 1.0.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 | Versions 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. |
.NET Core | netcoreapp2.2 is compatible. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
-
.NETCoreApp 2.2
- DocumentFormat.OpenXml (>= 2.9.1)
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 | 520 | 12/5/2019 | |
1.0.8 | 439 | 12/4/2019 | |
1.0.7 | 469 | 12/3/2019 | |
1.0.6 | 443 | 12/3/2019 | |
1.0.5 | 532 | 11/3/2019 | |
1.0.4 | 486 | 11/1/2019 | |
1.0.3 | 459 | 11/1/2019 | |
1.0.2 | 449 | 11/1/2019 | |
1.0.1 | 464 | 10/31/2019 | |
1.0.0 | 577 | 10/31/2019 | |
1.0.0-CI-20191101-070123 | 326 | 11/1/2019 | |
1.0.0-CI-20191101-070113 | 330 | 11/1/2019 |