![]() |
VOOZH | about |
dotnet add package Sylvan.Data.Excel --version 0.5.6
NuGet\Install-Package Sylvan.Data.Excel -Version 0.5.6
<PackageReference Include="Sylvan.Data.Excel" Version="0.5.6" />
<PackageVersion Include="Sylvan.Data.Excel" Version="0.5.6" />Directory.Packages.props
<PackageReference Include="Sylvan.Data.Excel" />Project file
paket add Sylvan.Data.Excel --version 0.5.6
#r "nuget: Sylvan.Data.Excel, 0.5.6"
#:package Sylvan.Data.Excel@0.5.6
#addin nuget:?package=Sylvan.Data.Excel&version=0.5.6Install as a Cake Addin
#tool nuget:?package=Sylvan.Data.Excel&version=0.5.6Install as a Cake Tool
A cross-platform .NET library for reading and writing Excel data files. The most commonly used formats: .xlsx, .xlsb and .xls, are supported for reading, while .xlsx and .xlsb formats are supported for writing.
ExcelDataReader provides readonly, row by row, forward-only access to the data. It provides a familiar API via DbDataReader, which is ideal for accessing rectangular, tabular data sets. It exposes a single, unified API for accessing all supported file formats.
ExcelDataWriter supports writing data from a DbDataReader to an Excel worksheet in .xlsx and .xlsb formats. ExcelDataWriter can only write a new Excel, it cannot be used to edit or append to existing files. It does not support custom formatting, charts, or other common features. It is meant only to export flat, rectangular data to Excel.
The library is a purely managed implementation with no external dependencies.
This library is currently the fastest and lowest allocating library for reading Excel data files in the .NET ecosystem, for all supported formats.
If you encounter any issues while using this library, please report an issue in the github repository. Be aware that I will be unlikely to investigate any issue unless an example file can be provided reproducing the issue.
Sylvan.Data.Excel Nuget Package
Install-Package Sylvan.Data.Excel
ExcelDataReader derives from DbDataReader, so it exposes an API that should be familiar for anyone who has worked with ADO.NET before. The field accessors allow reading data in an efficient, strongly-typed manner: GetString, GetInt32, GetDateTime, GetBoolean, etc.
The GetExcelDataType method allows inspecting the native Excel data type of a cell, which may vary from row to row. FieldCount, returns the number of columns in the header row, and doesn't change while processing each row in a sheet. RowFieldCount returns the number of fields in the current row, which might vary from row to row, and can be used to access cells in a "jagged", non-rectangular file.
The ExcelDataReader provides a forward only, row by row access to the data in a worksheet. It allows iterating over sheets using the NextResult() method, and iterating over rows using the Read() method. Fields are accessed using standard accessors, most commonly GetString(). GetString() is designed to not throw an exception, except in the case that a cell contains a formula error. The TryOpenWorksheet(string name) method can be used to open a specific, known worksheet.
using Sylvan.Data.Excel;
// ExcelDataReader derives from System.Data.DbDataReader
// The Create method can open .xls, .xlsx or .xlsb files.
using ExcelDataReader edr = ExcelDataReader.Create("data.xls");
do
{
var sheetName = edr.WorksheetName;
// enumerate rows in current sheet.
while(edr.Read())
{
// iterate cells in row.
// can use edr.RowFieldCount when sheet contains jagged, non-rectangular data
for(int i = 0; i < edr.FieldCount; i++)
{
var value = edr.GetString(i);
}
// Can use other strongly-typed accessors
// bool flag = edr.GetBoolean(0);
// DateTime date = edr.GetDateTime(1);
// decimal amt = edr.GetDecimal(2);
}
// iterates sheets
} while(edr.NextResult());
The Sylvan.Data library (a separate nuget package) includes a general-purpose data binder that can bind a DbDataReader to objects. This can be used to easily read an Excel file as a series of strongly typed objects.
using Sylvan.Data;
using Sylvan.Data.Excel;
using var edr = ExcelDataReader.Create("data.xlsx");
foreach (MyRecord item in edr.GetRecords<MyRecord>())
{
Console.WriteLine($"{item.Name} {item.Quantity}");
}
class MyRecord
{
public int Id { get; set; }
public string Name { get; set; }
public int? Quantity { get; set; }
public DateTime Date { get; set; }
}
The Sylvan.Data.Csv library can be used to convert Excel worksheet data to CSV.
using Sylvan.Data.Excel;
using Sylvan.Data.Csv;
using var edr = ExcelDataReader.Create("data.xlsx");
do
{
var sheetName = edr.WorksheetName;
using CsvDataWriter cdw = CsvDataWriter.Create("data-" + sheetName + ".csv")
cdw.Write(edr);
} while(edr.NextResult());
The ExcelDataWriter type is used to create Excel workbooks and write DbDataReader data as worksheets.
// *critical* to dispose (using) ExcelDataWriter.
using var edw = ExcelDataWriter.Create("data.xlsx");
DbDataReader dr;
dr = GetQueryResults("UserReport");
edw.Write(dr, "UserReport");
dr = GetQueryResults("SecurityAudit");
edw.Write(dr, "SecurityAudit");
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 is compatible. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 was computed. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 is compatible. |
| .NET Framework | net461 net461 was computed. net462 net462 was computed. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 5 NuGet packages that depend on Sylvan.Data.Excel:
| Package | Downloads |
|---|---|
|
GreatUtilities.Infrastructure
Essencial tools to agile development. |
|
|
Verify.Sylvan.Data.Excel
Extends Verify (https://github.com/VerifyTests/Verify) to allow verification via Sylvan.Data.Excel https://github.com/MarkPflug/Sylvan.Data.Excel/ |
|
|
MicroM.Core
MicroM, lightweight framework to create SQL Server Database centric apps. |
|
|
Purcell
一个超高性能的Excel强类型读写映射库。(支持.xls .xlsx .csv) |
|
|
Sylvan.AspNetCore.Mvc.Excel
Package Description |
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.5.6 | 22,688 | 5/8/2026 |
| 0.5.5 | 17,977 | 4/15/2026 |
| 0.5.4 | 8,099 | 3/20/2026 |
| 0.5.3 | 4,602 | 3/13/2026 |
| 0.5.2 | 105,512 | 11/7/2025 |
| 0.5.1 | 12,794 | 10/17/2025 |
| 0.5.0 | 13,831 | 9/19/2025 |
| 0.4.30 | 18,672 | 8/20/2025 |
| 0.4.29 | 11,491 | 7/23/2025 |
| 0.4.28 | 1,950 | 7/23/2025 |
| 0.4.27 | 42,748 | 6/27/2025 |
| 0.4.26 | 41,300 | 5/5/2025 |
| 0.4.26-b0001 | 7,692 | 12/3/2024 |
| 0.4.25 | 300,246 | 8/15/2024 |
| 0.4.25-b0001 | 242 | 8/14/2024 |
| 0.4.24 | 40,490 | 6/21/2024 |
| 0.4.23 | 10,741 | 6/3/2024 |
| 0.4.22 | 11,698 | 5/13/2024 |
| 0.4.21 | 1,274 | 5/5/2024 |
| 0.4.20 | 2,605 | 4/25/2024 |