Ninjanaut.BinaryExcelReader 2.1.0

The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org. Prefix Reserved
dotnet add package Ninjanaut.BinaryExcelReader --version 2.1.0
NuGet\Install-Package Ninjanaut.BinaryExcelReader -Version 2.1.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Ninjanaut.BinaryExcelReader" Version="2.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Ninjanaut.BinaryExcelReader --version 2.1.0
#r "nuget: Ninjanaut.BinaryExcelReader, 2.1.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Ninjanaut.BinaryExcelReader as a Cake Addin
#addin nuget:?package=Ninjanaut.BinaryExcelReader&version=2.1.0

// Install Ninjanaut.BinaryExcelReader as a Cake Tool
#tool nuget:?package=Ninjanaut.BinaryExcelReader&version=2.1.0

Ninjanaut.BinaryExcelReader

Welcome to the project website! BinaryExcelReader is lightweight C# library to ease loading data from binary Excel file format (XLSB) into DataTable object. Library is based on Microsoft OLE DB driver. Other formats XLS, XLSX and XLSM are also supported.

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 as A, B, B1, B11 (this is OLE DB Driver default setting).
  • Another options might be set via options parameter
Description Option Default Note
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;

// Convert excel sheet into datatable object.
var path = @"C:\FooExcel.xlsx";
var sheetName = "Sheet1";
var datatable = BinaryExcelReader.ToDataTable(path, sheetName);

You can also override the default settings using the options parameter.

using Ninjanaut.IO;

// Convert excel sheet into datatable object using options parameter.
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);

// Or the options object may be defined within the method directly.
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.

Release notes

Version Note
2.1.0 Add new ToDataTable(string path, BinaryExcelReaderOptions options = null) signature so that worksheet name does not need to be provided. <br/> When file is not found or accessible, the BinaryExcelReaderException is thrown. <br/> Minor fix in test project.
2.0.0 ReadData method was set as private.
1.0.0 Initial release

Contribution

If you would like to contribute to the project, please send a pull request to the dev branch.

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.1.0 205 4/17/2023
2.0.0 485 9/5/2021
1.0.0 346 9/4/2021