https://github.com/verifytests/verify.sylvan.data.excel
Extends Verify to allow verification of documents via Sylvan.Data.Excel.
https://github.com/verifytests/verify.sylvan.data.excel
Last synced: 9 months ago
JSON representation
Extends Verify to allow verification of documents via Sylvan.Data.Excel.
- Host: GitHub
- URL: https://github.com/verifytests/verify.sylvan.data.excel
- Owner: VerifyTests
- License: mit
- Created: 2025-04-30T22:32:40.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-06-16T09:06:31.000Z (about 1 year ago)
- Last Synced: 2025-06-18T14:07:51.186Z (12 months ago)
- Language: C#
- Homepage:
- Size: 98.6 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- 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.Sylvan.Data.Excel
[](https://github.com/orgs/VerifyTests/discussions)
[](https://ci.appveyor.com/project/SimonCropp/verify-sylvan-data-excel)
[](https://www.nuget.org/packages/Verify.Sylvan.Data.Excel/)
Code provided by Cédric Luthi https://github.com/0xced
Extends [Verify](https://github.com/VerifyTests/Verify) to allow verification of Excel documents via [Sylvan.Data.Excel](https://github.com/MarkPflug/Sylvan.Data.Excel/).
Converts Excel documents (xls, xlsb and 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.Sylvan.Data.Excel) is a major sponsor and is proud to contribute to the development this project.
[](https://entityframework-extensions.net/?utm_source=simoncropp&utm_medium=Verify.Sylvan.Data.Excel)
## NuGet
* https://nuget.org/packages/Verify.Sylvan.Data.Excel
## Usage
### Enable Verify.Sylvan.Data.Excel
```cs
[ModuleInitializer]
public static void Initialize() =>
VerifySylvanDataExcel.Initialize();
```
snippet source | anchor
### Excel
#### Verify a file
```cs
[Test]
public Task VerifyExcel() =>
VerifyFile("sample.xlsx");
```
snippet source | anchor
#### 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 ExcelDataReader
```cs
[Test]
public Task VerifyExcelDataReader()
{
using var stream = File.OpenRead("sample.xlsx");
using var reader = ExcelDataReader.Create(stream, ExcelWorkbookType.ExcelXml);
return Verify(reader);
}
```
snippet source | anchor
### Example snapshot
```csv
0,First Name,Last Name,Gender,Country,Date,Age,Id,Formula
1,Dulce,Abril,Female,United States,2017-10-15,32,1562,1594
2,Mara,Hashimoto,Female,Great Britain,2016-08-16,25,1582,1607
3,Philip,Gent,Male,France,2015-05-21,36,2587,2623
4,Kathleen,Hanner,Female,United States,2017-10-15,25,3549,3574
5,Nereida,Magwood,Female,United States,2016-08-16,58,2468,2526
6,Gaston,Brumm,Male,United States,2015-05-21,24,2554,2578
```
snippet source | anchor
### CsvDataWriterOptions
Used to configure options for writing CSV data.
```cs
[Test]
public Task CsvDataWriterOptions()
{
using var stream = File.OpenRead("sample.xlsx");
var options = new CsvDataWriterOptions
{
Delimiter = '\t',
Quote = '"',
};
return Verify(stream)
.CsvDataWriterOptions(options);
}
```
snippet source | anchor