Ninjanaut.BinaryExcelReader
1.0.0
Prefix Reserved
See the version list below for details.
dotnet add package Ninjanaut.BinaryExcelReader --version 1.0.0
NuGet\Install-Package Ninjanaut.BinaryExcelReader -Version 1.0.0
<PackageReference Include="Ninjanaut.BinaryExcelReader" Version="1.0.0" />
paket add Ninjanaut.BinaryExcelReader --version 1.0.0
#r "nuget: Ninjanaut.BinaryExcelReader, 1.0.0"
// Install Ninjanaut.BinaryExcelReader as a Cake Addin #addin nuget:?package=Ninjanaut.BinaryExcelReader&version=1.0.0 // Install Ninjanaut.BinaryExcelReader as a Cake Tool #tool nuget:?package=Ninjanaut.BinaryExcelReader&version=1.0.0
Welcome to the BinaryExcelReader project website! BinaryExcelReader is lightweight C# library to ease loading data from Excel binary (xlsb) file format into DataTable object, based on Microsoft OLE DB Driver. Also supports xls, xlsx and xlsm formats.
if you don't need to load .XLSB format, consider to use excel reader without OLE DB Driver dependency Ninjanaut.ExcelReader
Installation
from nuget package manager console
PM> Install-Package Ninjanaut.BinaryExcelReader
from command line
> dotnet add package Ninjanaut.BinaryExcelReader
Version | Targets |
---|---|
1.x | .NET 5 |
Features
- Loading from file path via sheet name.
- Duplicate columns are implicitly allowed.
- Columns
A, B, B, B1
will be loaded asA, B, B1, B11
(this is OLE DB Driver default setting).
- Columns
- Another options might be set via options parameter
Descriptions | Options | Defaults | Notes |
---|---|---|---|
Skip top rows | HeaderRowIndex | 0 | Keep in mind that OLE DB driver does not take into account blank rows. For example, if you have 4 additional non-header rows from top and two of them are blank, the header row index is 2. Warning: if the row contains formatting, it is not considered blank. |
Remove empty rows | RemoveEmptyRows | true | If set to false and the row does not contains anything (even formatting), then the row will not be loaded anyway. |
Limit max columns to load | MaxColumns | null | I recommend setting this value so that you don't accidentally load empty columns. |
Skip header row | HeaderExists | true | If set to false, HeaderRowIndex property is ignored. |
Usage
using Ninjanaut.IO;
// From file path
var path = @"C:\FooExcel.xlsx";
var sheetName = "Sheet1"
var datatable = BinaryExcelReader.ToDataTable(path, sheetName);
you can also use options argument
using Ninjanaut.IO;
var path = @"C:\FooExcel.xlsx";
var sheetName = "Sheet1"
var options = new BinaryExcelReaderOptions
{
// Default settings:
HeaderExists = true
HeaderRowIndex = 0,
RemoveEmptyRows = true,
MaxColumns = null,
});
var datatable = BinaryExcelReader.ToDataTable(path, sheetName, options);
// The options may be defined within the method.
var datatable = ExcelReader.ToDataTable(path, sheetName, new() { MaxColumns = 5 });
Notes
DataTable object is suitable for this purpose, because you can easily view the read data directly in Visual Studio for debug purposes, create a collection of entities from it or pass datatable as parameter directly into the SQL server stored procedure.
Contribution
If you would like to contribute to the project, please send a pull request to the dev branch.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net5.0
- System.Data.OleDb (>= 5.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.