An open API service indexing awesome lists of open source software.

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.

Awesome Lists containing this project

README

          

# Verify.Sylvan.Data.Excel

[![Discussions](https://img.shields.io/badge/Verify-Discussions-yellow?svg=true&label=)](https://github.com/orgs/VerifyTests/discussions)
[![Build status](https://ci.appveyor.com/api/projects/status/q1eqcnbptyjl24hp?svg=true)](https://ci.appveyor.com/project/SimonCropp/verify-sylvan-data-excel)
[![NuGet Status](https://img.shields.io/nuget/v/Verify.Sylvan.Data.Excel.svg)](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.

[![Entity Framework Extensions](https://raw.githubusercontent.com/VerifyTests/Verify.Sylvan.Data.Excel/refs/heads/main/docs/zzz.png)](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