Smpl.Excel 1.0.2

dotnet add package Smpl.Excel --version 1.0.2
                    
NuGet\Install-Package Smpl.Excel -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="Smpl.Excel" Version="1.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Smpl.Excel" Version="1.0.2" />
                    
Directory.Packages.props
<PackageReference Include="Smpl.Excel" />
                    
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 Smpl.Excel --version 1.0.2
                    
#r "nuget: Smpl.Excel, 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 Smpl.Excel@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=Smpl.Excel&version=1.0.2
                    
Install as a Cake Addin
#tool nuget:?package=Smpl.Excel&version=1.0.2
                    
Install as a Cake Tool

SimpleExcel

A simple and lightweight library for generating Excel files (.xlsx) from .NET objects with fluent API. Supports only two fonts (Arial and Calibri) and sizes from 6 to 16 points, because auto column width calculation requires font metrics. Columns and dynamic columns can be hidden from the Excel output using the hidden parameter.

NuGet License: MIT

Features

  • 🚀 Fluent API: Easy-to-use fluent interface for building Excel reports
  • 🧊 Frozen Header Row: Keeps the header row visible while scrolling
  • 📊 Dynamic Columns: Support for dynamic column generation based on data collections
  • 📏 Auto-sizing: Automatic column width calculation based on content
  • 🔍 Filtering: Built-in auto-filter support on all columns
  • 🎯 Broad Compatibility: Targets .NET Standard 2.0 (supports .NET Framework 4.6.1+, .NET Core 2.0+, .NET 5+)

Installation

dotnet add package SimpleExcel

Or via Package Manager Console:

Install-Package SimpleExcel

Quick Start

using SimpleExcel;
using SimpleExcel.Font;
using System.Drawing;

// Sample data
var people = new[]
{
    new { Name = "John", Surname = "Doe", Age = 30, Email = "john@example.com" },
    new { Name = "Jane", Surname = "Smith", Age = 25, Email = "jane@example.com" }
};

// Generate Excel file
var excelBytes = new WorksheetGenerator<dynamic>("People Report")
    .Column("First Name", p => p.Name)
    .Column("Last Name", p => p.Surname)
    .Column("Age", p => p.Age)
    .Column("Email", p => p.Email)
    .GenerateAsBytes(people);

// Save to file
File.WriteAllBytes("people.xlsx", excelBytes);

Advanced Usage Examples

Font and Styling Options

var generator = new WorksheetGenerator<MyClass>("Styled Report")
    .SetFont(Fonts.Calibri)           // Available: Fonts.Arial, Fonts.Calibri
    .SetFontSize(FontSize.pt10)       // Available: pt6, pt7, pt8, pt9, pt10, pt11, pt12, pt13, pt14, pt15, pt16
    .SetHeaderBackColor(Color.Navy)   // Any System.Drawing.Color
    .SetHeaderTextColors(Color.Yellow);

Hidden Columns

Columns and dynamic columns can be hidden from the Excel output using the hidden parameter:

var generator = new WorksheetGenerator<MyClass>("Report")
    .Column("Visible Name", x => x.Name)
    .Column("Internal ID", x => x.Id, hidden: true)  // Hidden from Excel output
    .Column("Email", x => x.Email);

Dynamic Columns

If you have subcollection properties that you want to represent as multiple columns in the Excel output, you can use the DynamicColumns method. When configuring subcolumns inside DynamicColumns, you can use the {nr} placeholder in the column header names to automatically number them.

Example Output Structure:

| Name | Surname | Code1 | 1. Skill    | Code2 | 2. Skill | Code3 | 3. Skill | Age | Project Title | Budget |
|------|---------|-------|-------------|-------|----------|-------|----------|-----|---------------|--------|
| John | Doe     | C#    | Programming | SQL   | Database | JS    | Frontend | 30  | Website       | 5000   |
| Jane | Smith   | Java  | Backend     |       |          |       |          | 25  | Mobile App    | 8000   |

Example Code:

using SimpleExcel;
using SimpleExcel.Font;
using System.Drawing;

// Sample data structure
public class Employee
{
    public string Name { get; set; }
    public string Surname { get; set; }
    public int Age { get; set; }
    public DateTime? StartDate { get; set; }
    public decimal? Salary { get; set; }
    
    // Collections for dynamic columns
    public ICollection<Skill> Skills { get; set; }
    public ICollection<Project> Projects { get; set; }
}

public class Skill
{
    public string Name { get; set; }
    public string Code { get; set; }
}

public class Project
{
    public string Title { get; set; }
    public decimal? Budget { get; set; }
}

// Generate Excel with dynamic columns
var employees = GetEmployeeData(); // Your data source

var excelBytes = new WorksheetGenerator<Employee>("Employee Report")
    .SetFont(Fonts.Arial)                   // Set font (default: Calibri)
    .SetFontSize(FontSize.pt14)             // Set font size (default: pt12)
    .SetHeaderBackColor(Color.BlueViolet)   // Set header background (default: DarkBlue)
    .SetHeaderTextColors(Color.Yellow)      // Set header text color (default: White)
    
    // Static columns
    .Column("Name", x => x.Name)
    .Column("Surname", x => x.Surname)
    
    // Dynamic columns from Skills collection
    .DynamicColumns(x => x.Skills, conf => conf
        .Column("Code{nr}", skill => skill.Code)      // {nr} gets replaced with 1, 2, 3...
        .Column("{nr}. Skill", skill => skill.Name))   // Creates: "1. Skill", "2. Skill", etc.
    
    // More static columns
    .Column("Age", x => x.Age)
    .Column("Salary", x => x.Salary)
    .Column("Start Date", x => x.StartDate)
    
    // Another set of dynamic columns from Projects collection
    .DynamicColumns(x => x.Projects, conf => conf
        .Column("Project Title", proj => proj.Title)
        .Column("Budget", proj => proj.Budget))
    
    .GenerateAsBytes(employees);

File.WriteAllBytes("employee_report.xlsx", excelBytes);

Requirements

  • .NET Standard 2.0 or higher
  • Compatible with:
    • .NET Framework 4.6.1+
    • .NET Core 2.0+
    • .NET 5, 6, 7, 8, 9+
    • Xamarin
    • Unity 2018.1+

License

MIT License - see LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Repository

https://github.com/ecizevskis/simple-excel

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  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 is compatible.  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.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.
  • net6.0

    • No dependencies.
  • net8.0

    • No dependencies.

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.2 207 10/2/2025