https://github.com/verifytests/verify.closedxml
Extends Verify to allow verification of Excel documents via ClosedXML.
https://github.com/verifytests/verify.closedxml
Last synced: 4 months ago
JSON representation
Extends Verify to allow verification of Excel documents via ClosedXML.
- Host: GitHub
- URL: https://github.com/verifytests/verify.closedxml
- Owner: VerifyTests
- License: mit
- Created: 2024-11-15T09:21:24.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2026-01-28T20:57:51.000Z (5 months ago)
- Last Synced: 2026-01-29T00:57:24.790Z (5 months ago)
- Language: C#
- Homepage:
- Size: 305 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- Funding: .github/FUNDING.yml
- License: license.txt
- Code of conduct: code_of_conduct.md
Awesome Lists containing this project
README
#
Verify.ClosedXml
[](https://github.com/orgs/VerifyTests/discussions)
[](https://ci.appveyor.com/project/SimonCropp/verify-closedxml)
[](https://www.nuget.org/packages/Verify.ClosedXml/)
Extends [Verify](https://github.com/VerifyTests/Verify) to allow verification of Excel documents via [ClosedXML](https://github.com/ClosedXML/ClosedXML).
Converts Excel documents (xlsx) to csv for verification.
**See [Milestones](../../milestones?state=closed) for release notes.**
## Sponsors
### Entity Framework Extensions
[Entity Framework Extensions](https://entityframework-extensions.net/?utm_source=simoncropp&utm_medium=Verify.ClosedXml) is a major sponsor and is proud to contribute to the development this project.
[](https://entityframework-extensions.net/?utm_source=simoncropp&utm_medium=Verify.ClosedXml)
## NuGet
* https://nuget.org/packages/Verify.ClosedXml
## Usage
### Enable Verify.ClosedXml
```cs
[ModuleInitializer]
public static void Initialize() =>
VerifyClosedXml.Initialize();
```
snippet source | anchor
### Input
For a given input Excel file.

### Verify a file
```cs
[Test]
public Task VerifyExcel() =>
VerifyFile("sample.xlsx");
```
snippet source | anchor
### Snapshot Result
For a given Verify, the result is 3 (or more files)
#### Metadata
```txt
{
SheetNames: [
Sheet1
],
Properties: {
Title: The Title
},
WorksheetCount: 1,
DefaultFont: Arial,
CalculateMode: Default,
Style: {
Font: {
Name: Arial
}
}
}
```
snippet source | anchor
#### CSV
One per sheet
```csv
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)
```
snippet source | anchor
#### Excel file

### Verify a Stream
```cs
[Test]
public Task VerifyExcelStream()
{
var stream = new MemoryStream(File.ReadAllBytes("sample.xlsx"));
return Verify(stream, "xlsx");
}
```
snippet source | anchor
### Verify a ClosedXML SpreadsheetDocument
```cs
[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);
}
```
snippet source | anchor