Verify.ClosedXml
April 9, 2026 ยท View on GitHub
Extends Verify to allow verification of Excel documents via ClosedXML.
Converts Excel documents (xlsx) to csv for verification.
See Milestones for release notes.
Sponsors
Entity Framework Extensions
Entity Framework Extensions is a major sponsor and is proud to contribute to the development this project.
Developed using JetBrains IDEs
NuGet
Usage
Enable Verify.ClosedXml
[ModuleInitializer]
public static void Initialize() =>
VerifyClosedXml.Initialize();
Input
For a given input Excel file.
Verify a file
[Test]
public Task VerifyExcel() =>
VerifyFile("sample.xlsx");
Snapshot Result
For a given Verify, the result is 3 (or more files)
Metadata
{
SheetNames: [
Sheet1
],
Properties: {
Title: The Title
},
WorksheetCount: 1,
DefaultFont: Arial,
CalculateMode: Default,
Style: {
Font: {
Name: Arial
}
}
}
CSV
One per sheet
0,First Name,Last Name,Gender,Country,Date,Age,Id,Formula
1,Dulce,Abril,Female,United States,DateTime_1,32,1562,1594 (G2+H2)
2,Mara,Hashimoto,Female,Great Britain,DateTime_2,25,1582,1607 (G3+H3)
3,Philip,Gent,Male,France,DateTime_3,36,2587,2623 (G4+H4)
4,Kathleen,Hanner,Female,United States,DateTime_1,25,3549,3574 (G5+H5)
5,Nereida,Magwood,Female,United States,DateTime_2,58,2468,2526 (G6+H6)
6,Gaston,Brumm,Male,United States,DateTime_3,24,2554,2578 (G7+H7)
Excel file
Verify a Stream
[Test]
public Task VerifyExcelStream()
{
var stream = new MemoryStream(File.ReadAllBytes("sample.xlsx"));
return Verify(stream, "xlsx");
}
Verify a ClosedXML SpreadsheetDocument
[Test]
public Task XLWorkbook()
{
using var book = new XLWorkbook();
var sheet = book.Worksheets.Add("Basic Data");
sheet.Cell("A1").Value = "ID";
sheet.Cell("B1").Value = "Name";
sheet.Cell("A2").Value = 1;
sheet.Cell("B2").Value = "John Doe";
sheet.Cell("A3").Value = 2;
sheet.Cell("B3").Value = "Jane Smith";
return Verify(book);
}
Binary output across .NET frameworks
When verifying binary package output (xlsx, docx, nupkg, etc.) across multiple target frameworks (e.g. net48 and net10.0), the binary output may differ due to Deflate compression implementation differences. The XML content within entries is identical โ only the compressed bytes differ. Use UniqueForRuntime to generate framework-specific verified files:
await Verify(stream, extension: "xlsx")
.UniqueForRuntime();
See Verify Naming docs for more details.

