Faysil.ExcelGenerator
1.0.0
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Faysil.ExcelGenerator --version 1.0.0
NuGet\Install-Package Faysil.ExcelGenerator -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="Faysil.ExcelGenerator" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Faysil.ExcelGenerator" Version="1.0.0" />
<PackageReference Include="Faysil.ExcelGenerator" />
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 Faysil.ExcelGenerator --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Faysil.ExcelGenerator, 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.
#:package Faysil.ExcelGenerator@1.0.0
#: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=Faysil.ExcelGenerator&version=1.0.0
#tool nuget:?package=Faysil.ExcelGenerator&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
ExcelGenerator
A lightweight .NET library to generate Excel files from IEnumerable<T> collections using ClosedXML.
Supported Frameworks
- .NET 9.0
Installation
dotnet add package ExcelGenerator
Or via NuGet Package Manager:
Install-Package ExcelGenerator
Features
- ✅ Generate Excel files from any
IEnumerable<T>orList<T> - ✅ Customizable header colors
- ✅ Option to exclude columns ending with "Id"
- ✅ Automatic summation row for decimal columns
- ✅ Auto-formatted column headers (PascalCase to spaced text)
- ✅ Auto-fit column widths
- ✅ Multiple output formats: File, Byte Array, Stream, or XLWorkbook
Quick Start
Basic Usage
using ExcelGenerator;
using ClosedXML.Excel;
// Your data
var products = new List<Product>
{
new Product { ProductId = 1, Name = "Laptop", Price = 999.99m, Quantity = 10 },
new Product { ProductId = 2, Name = "Mouse", Price = 29.99m, Quantity = 50 },
new Product { ProductId = 3, Name = "Keyboard", Price = 79.99m, Quantity = 30 }
};
// Generate and save to file
ExcelSheetGenerator.GenerateExcelFile(
data: products,
sheetName: "Products",
filePath: "products.xlsx",
excludeIds: true, // Removes ProductId column
headerColor: XLColor.Green // Custom header color
);
Get as Byte Array (for web downloads)
byte[] excelBytes = ExcelSheetGenerator.GenerateExcelBytes(
data: products,
sheetName: "Products",
excludeIds: true
);
// In ASP.NET Core
return File(excelBytes, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "products.xlsx");
Get as Stream
using var stream = ExcelSheetGenerator.GenerateExcelStream(
data: products,
sheetName: "Products"
);
Get XLWorkbook (for advanced customization)
using var workbook = ExcelSheetGenerator.GenerateExcel(
data: products,
sheetName: "Products",
excludeIds: false,
headerColor: XLColor.LightBlue
);
// Add more sheets, customize, etc.
workbook.SaveAs("output.xlsx");
Parameters
| Parameter | Type | Description |
|---|---|---|
data |
IEnumerable<T> |
The collection of objects to export |
sheetName |
string |
Name of the Excel worksheet |
excludeIds |
bool |
If true, excludes columns ending with "Id" or "ID" |
headerColor |
XLColor? |
Background color for header row (default: LightBlue) |
Output Features
- Headers: Automatically formatted from PascalCase (e.g.,
ProductName→Product Name) - Numbers: Formatted with thousand separators
- Decimals: Displayed with 2 decimal places
- Dates: Formatted as
yyyy-MM-dd HH:mm:ss - Booleans: Displayed as "Yes" or "No"
- Summation Row: Automatically added for decimal columns at the bottom
Dependencies
- ClosedXML (v0.105.0+)
License
MIT License
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net9.0
- ClosedXML (>= 0.105.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
v1.0.0 - Initial release: Generate Excel files from IEnumerable collections with customizable headers, automatic decimal summation rows, and Id column exclusion option.