XlsxHelper 1.0.0

dotnet add package XlsxHelper --version 1.0.0
NuGet\Install-Package XlsxHelper -Version 1.0.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="XlsxHelper" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add XlsxHelper --version 1.0.0
#r "nuget: XlsxHelper, 1.0.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 XlsxHelper as a Cake Addin
#addin nuget:?package=XlsxHelper&version=1.0.0

// Install XlsxHelper as a Cake Tool
#tool nuget:?package=XlsxHelper&version=1.0.0

XlsxHelper

alternate text is missing from this package README image

XlsxHelper has been crafted with the primary intention of efficiently parsing extensive Excel files. This library is designed to be lightweight, ensuring that it doesn't load the entire dataset into memory all at once. Instead, it adopts a sequential approach, fetching and returning one row per iteration. As a result of this methodology, the memory overhead is minimized.

When to use XlsxHelper

  • You need to process large xlsx file.
  • You want to read content with very little RAM usage.
  • You want full control of mapping/parsing fields to Model.

When to not use XlsxHelper

  • You want to read rows in random manner.
  • You want to read thing like width of row/column, font size / color etc
  • You want to read xls file format.

Example 1

using (var workbook = XlsxReader.OpenWorkbook(filePath))
{
    foreach (var worksheet in workbook.Worksheets)//read all worksheets
    {
        Console.WriteLine($"Worksheet {worksheet.Name}"); //get name of worksheet
        using var worksheetReader = worksheet.WorksheetReader; //get WorksheetReader from worksheet
        await foreach (var row in worksheetReader) //read row from worksheetreader
        {
            Console.WriteLine($"Content of row {row.RowNumber}"); //display current row number
            foreach (var cell in row.Cells) // Display all cell content
            {
                Console.WriteLine($"[{cell.CellValue} at ({cell.ColumnName}{row.RowNumber})]");
            }
            Console.WriteLine($"Content of row {row.RowNumber} ends.");
        }
    }
}

Example 2

using (var workbook = XlsxReader.OpenWorkbook(filePath))
{
    var worksheet = workbook.Worksheets.First();
    bool headerRow = true;
    Dictionary<string, ColumnName> headerLooklup = null;
    await foreach (var row in worksheet.WorksheetReader)
    {
        if (headerRow)
        {
            headerLooklup = ReadHeader(row); //Read all header names from first row
            headerRow = false;
            continue;
        }
        var student = new Student();
        student.FirstName = row[headerLooklup[nameof(Student.FirstName)]].CellValue; //get cell value 
        student.LastName = row[headerLooklup[nameof(Student.LastName)]].CellValue;
        student.Grade = row[headerLooklup[nameof(student.Grade)]].CellValue;
        student.Marks = new Marks
        {
            Biology = row[headerLooklup[nameof(Marks.Biology)]].GetInt32(),
            Chemistry = row[headerLooklup[nameof(Marks.Chemistry)]].GetInt32(),
            Mathematics = row[headerLooklup[nameof(Marks.Mathematics)]].GetInt32(),
            Physics = row[headerLooklup[nameof(Marks.Physics)]].GetInt32()
        };

        //Process student object. 
        //yield return student;
    }

    static Dictionary<string, ColumnName> ReadHeader(Row row) //read header
    {
        Dictionary<string, ColumnName> headerLooklup = new Dictionary<string, ColumnName>();
        foreach (var cell in row.Cells)
        {
            headerLooklup.Add(cell.CellValue, cell.ColumnName);
        }
        return headerLooklup;
    }
}
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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.
  • net6.0

    • No dependencies.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0 1 8/21/2023