Halifax.Excel 6.5.0

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

Halifax Service Foundation

Simple libraries for complex projects. Halifax removes the boilerplate from .NET API services: standardized responses, exception mapping, JWT auth, configuration, logging and more, so you can focus on business logic.

CI NuGet

Package NuGet Description
Halifax.Api NuGet ASP.NET Core integration: middleware, OpenAPI, Scalar UI
Halifax.Core NuGet JWT, configuration, validation, encryption, logging, JSON
Halifax.Domain NuGet Response models, exceptions, pagination
Halifax.Http NuGet Typed HttpClient with error mapping and resilience
Halifax.Excel NuGet Excel and CSV import and export

Documentation

This page is the overview. Each area has its own page with the details:

Guide Covers
Service setup AddHalifax/UseHalifax, every builder method, OpenAPI, Scalar, CORS, version endpoint
Responses and errors ApiResponse, exception mapping, stack traces in errors, custom handlers, pagination
Configuration .env files, settings types, supported types, parsing rules
Authentication JWT setup, secrets, creating and reading tokens, claims checks
HTTP client Typed clients, error mapping, resilience, correlation IDs
Logging The L logger, ASP.NET Core's own logs
Excel and CSV Reading and writing, multi-sheet workbooks, SkiaSharp-free reading
Utilities Encryption formats, short IDs, JSON, dates, extensions

Compatibility

Each Halifax major version targets one .NET major version. Pick the line that matches your app's target framework, and keep all Halifax.* packages in one app on the same major version.

Halifax.Api, .Core, .Domain, .Http Halifax.Excel .NET Target framework
6.x 6.x .NET 11 net11.0
5.x 0.2.x to 0.4.x .NET 10 net10.0
4.x 0.1.x .NET 9 net9.0
3.x 0.0.6 to 0.0.11 .NET 8 net8.0
2.x 0.0.1 to 0.0.5 .NET 7 net7.0
1.x not available .NET 6 net6.0

Starting with 6.0.0, Halifax.Excel is stable and shares the major version with the other packages. Older lines stay on NuGet but get no further updates; new features and fixes go to the latest line only.

Minor and patch releases keep existing behavior as the default: anything that would change what a running service returns, stores or logs is opt-in.

Quick Start

dotnet add package Halifax.Api
using Halifax.Api;

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddHalifax();

var app = builder.Build();
app.UseHalifax();
app.Run("https://*:5000");

This gives you controllers, exception mapping, an OpenAPI document at /openapi/v1.json, the Scalar UI at /scalar, CORS that allows any origin, correlation IDs, a version endpoint and console logging. See the Peggy's Cove sample for a full working app, and Service setup for every option.

Responses and Errors

[HttpGet("{id}")]
public async Task<ApiResponse<UserDto>> Get(int id)
{
    var user = await db.Users.FindAsync(id)
        ?? throw new HalifaxNotFoundException("User not found");   // 404

    return ApiResponse.With(new UserDto(user.Id, user.Name));
}

Success is { "data": ..., "success": true, "error": null }. HalifaxException maps to 400, HalifaxUnauthorizedException to 401, HalifaxNotFoundException to 404 and anything else to 500, with { "success": false, "error": { "type", "message", "trace" } }. trace is the stack trace; turn it off for public APIs with ConfigureErrorTrace(false). More

Configuration

AppSettings__ConnectionString=localhost
AppSettings__HttpTimeout=120
record AppSettings(string ConnectionString, int HttpTimeout);

builder.Services.AddHalifax(h => h.AddSettings<AppSettings>());

AddHalifax loads the nearest .env file; AddSettings<T>() binds T from {TypeName}__{Member} variables and registers it as a singleton. Strings, bool, numbers, decimal, Guid, dates, times, enums and their nullable versions are supported, parsed with the invariant culture. More

Authentication

builder.Services.AddHalifax(h => h.ConfigureAuthentication(jwtSecret));

string token = Jwt.Create(jwtSecret, claims, DateTime.UtcNow.AddDays(30));
List<Claim> read = Jwt.Read(jwtSecret, token);

Endpoints marked [Authorize] then require Authorization: Bearer {token}. Use a secret of at least 32 characters. For checks on claims, derive from ClaimsAuthorizeFilterAttribute. More

Validation

Guard methods throw HalifaxException (400) when a check fails:

Guard.NotNullOrWhiteSpace(request.Name, nameof(request.Name));
Guard.Email(request.Email);
Guard.Length(request.Password, nameof(request.Password), lower: 8, upper: 64);
Guard.Range(request.Age, nameof(request.Age), from: 18, to: 120);
Guard.Url(request.Website, nameof(request.Website));
Guard.Ensure(request.AcceptedTerms, "Terms must be accepted");
Guard.NotNull(request.Address, nameof(request.Address));
Guard.NotEmptyList(request.Tags, nameof(request.Tags));
Guard.Color(request.Theme, nameof(request.Theme));

Also available: Guard.StringWithEmails for a list of addresses in one string.

HTTP Client

public class PaymentClient(HttpClient http) : HalifaxHttpClient(http)
{
    public Task<PaymentDto> GetAsync(string id) =>
        SendAsync<PaymentDto>(CreateMessage(HttpMethod.Get, $"/api/payments/{id}"));
}

builder.Services.AddHalifaxHttpClient<PaymentClient>(
    defaultBaseUrl: "https://payments.api.com",
    defaultBearerToken: token);

SendAsync<T> deserializes the response and throws on a failed one. Resilience policies and correlation ID forwarding are one call each. More

Logging

L.Info("User {UserId} created", userId);
L.Error(exception, "Failed to process order {OrderId}", orderId);

L is a static Serilog console logger. ASP.NET Core's own logs are kept quiet; ConfigureFrameworkLogging(LogLevel.Warning) shows them. More

Excel & CSV

dotnet add package Halifax.Excel
var converter = new ExcelConverter<Person>();
converter.AddMapping("Full Name", p => p.Name);

var people = await converter.ReadAsync(file.OpenReadStream(), file.ContentType);   // .xlsx, .xls or CSV

var stream = new MemoryStream();
await converter.WriteExcelAsync(stream, people, "People");   // stream stays open and is rewound
return File(stream, ExcelContentType.Xlsx, "People.xlsx");

ExcelWorkbookWriter puts several sheets of different types into one workbook (or rows whose columns are known only at run time), and CsvFile writes CSV from dictionary or dynamic rows. A bad cell throws ExcelConversionException with its row and column. Halifax.Excel does not need SkiaSharp. More

Utilities

var encrypted = Crypto.Encrypt(secret, "sensitive data");   // CryptoFormat.Legacy unless you opt in to AesGcm
var decrypted = Crypto.Decrypt(secret, encrypted);         // reads both formats

var id = ShortId.Create();                                 // e.g. "kX9mBnQ"
var json = Json.Serialize(obj);

Crypto.Encrypt(secret, text) keeps writing the format every Halifax version reads; CryptoFormat.AesGcm, chosen per call, adds authenticated, randomized encryption for values that are decrypted and never compared. More

Package Overview

Package Dependencies
Halifax.Domain none
Halifax.Core Halifax.Domain, Serilog, Serilog.Sinks.Console, Destructurama.Attributed, System.IdentityModel.Tokens.Jwt, Microsoft.Extensions.Logging
Halifax.Api Halifax.Core, Swashbuckle.AspNetCore, Scalar.AspNetCore, Microsoft.AspNetCore.Authentication.JwtBearer
Halifax.Http Halifax.Core, Microsoft.Extensions.Http.Resilience
Halifax.Excel NPOI

All packages target .NET 11 with nullable reference types enabled. For older .NET versions see Compatibility.

MIT License

Copyright (c) 2020-2026 Andrei M

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Product Compatible and additional computed target framework versions.
.NET net11.0 is compatible. 
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
6.5.0 150 11/25/2026
6.4.0 103 11/24/2026
6.3.0 87 11/24/2026
6.2.0 131 11/24/2026
6.1.0 108 11/24/2026
6.0.0 182 11/16/2026
0.4.5 148 11/2/2026
0.4.4 97 11/2/2026
0.4.3 178 10/22/2026
0.4.2 334 9/16/2026
0.4.1 293 8/12/2026
0.4.0 628 7/13/2026
0.3.2 349 5/28/2026
0.3.1 626 3/2/2026
0.3.0 229 3/2/2026
0.2.1 435 1/28/2026
0.2.0 779 11/14/2025
0.1.5 649 9/3/2025
0.1.4 572 7/17/2025
0.1.3 406 7/15/2025
Loading failed

v6.5.0 - ExcelWorkbookWriter.AddRows writes a sheet of rows with run-time columns (header plus values), styled like a typed sheet
           v6.4.0 - CsvFile.ReadAsync reads raw CSV records (header first) with the same parser as ExcelConverter, for your own column mapping
           v6.3.0 - CsvFile.WriteAsync writes dictionary and dynamic rows (e.g. Dapper's) as CSV, byte for byte what CsvHelper's defaults wrote for dynamic records
           v6.2.0 - CSV is read and written by Halifax itself: CsvHelper is no longer a dependency (NPOI is the only one left). Same results as 6.1.0 for every input, pinned by tests. Microsoft.Build.Tasks.Git is no longer listed as a package dependency; Excel-specific package tags; documentation
           v6.1.0 - Own Excel reader replaces ExcelMapper and needs no SkiaSharp (a number read into a text property no longer fails); headers match case-insensitively; a bad cell throws ExcelConversionException naming the row and column. New ExcelWorkbookWriter for several sheets in one workbook, Exclude, ExcelCell.GetText, ExcelContentType constants and ReadExcel by sheet name. Dates are written as date cells. Writes leave the stream open and rewound. NPOI's unusable native SkiaSharp libraries (10.6 MB on linux-x64) no longer reach consumers
           v6.0.0 - First stable release, aligned with the Halifax 6 line. .NET 11 support, CSV moved to CsvHelper 34, package dependency updates
           v0.4.5 - Add Source Link and a symbol package (snupkg) for source-level debugging
           v0.4.4 - Package dependency updates
           v0.4.3 - Package dependency updates
           v0.4.2 - Package dependency updates, pin Microsoft.Build.Tasks.Git to patch transitive vulnerability
           v0.4.1 - Ship XML documentation in the package, enrich API docs, dependency updates
           v0.4.0 - Package dependency updates, pin System.Security.Cryptography.Xml to patch transitive vulnerability
           v0.3.2 - Package dependency updates, NPOI license acceptance
           v0.3.1 - Bug fixes, DateTime support, comprehensive tests
           v0.3.0 - Nullable reference types, trace warnings for conversion failures
           v0.2.x - .NET 10 support
           v0.1.x - .NET 9 support
           v0.x.x - Alpha release