MeshWeaver.DataSetReader.Excel.BinaryFormat 2.0.3

dotnet add package MeshWeaver.DataSetReader.Excel.BinaryFormat --version 2.0.3
                    
NuGet\Install-Package MeshWeaver.DataSetReader.Excel.BinaryFormat -Version 2.0.3
                    
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="MeshWeaver.DataSetReader.Excel.BinaryFormat" Version="2.0.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MeshWeaver.DataSetReader.Excel.BinaryFormat" Version="2.0.3" />
                    
Directory.Packages.props
<PackageReference Include="MeshWeaver.DataSetReader.Excel.BinaryFormat" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add MeshWeaver.DataSetReader.Excel.BinaryFormat --version 2.0.3
                    
#r "nuget: MeshWeaver.DataSetReader.Excel.BinaryFormat, 2.0.3"
                    
#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.
#addin nuget:?package=MeshWeaver.DataSetReader.Excel.BinaryFormat&version=2.0.3
                    
Install MeshWeaver.DataSetReader.Excel.BinaryFormat as a Cake Addin
#tool nuget:?package=MeshWeaver.DataSetReader.Excel.BinaryFormat&version=2.0.3
                    
Install MeshWeaver.DataSetReader.Excel.BinaryFormat as a Cake Tool

MeshWeaver.DataSetReader.Excel.BinaryFormat

MeshWeaver.DataSetReader.Excel.BinaryFormat is a specialized implementation for reading legacy Excel (.xls) files in the BIFF (Binary Interchange File Format) format. It provides comprehensive support for reading Excel 97-2003 workbooks with their complex binary structure.

Overview

The library provides:

  • Complete BIFF format support
  • Excel 97-2003 workbook reading
  • Cell format handling
  • Shared string table support
  • Multi-sheet workbook handling
  • Formula cell support

Architecture

Core Components

ExcelBinaryReader

Main reader implementation providing:

  • Workbook structure parsing
  • Sheet content reading
  • Cell value extraction
  • Format conversion
BIFF Record Types

Specialized handlers for various BIFF records:

  • BOF (Beginning of File)
  • Worksheet data
  • Cell content
  • Formatting information
  • Shared strings
  • Formula cells

Binary Format Support

Workbook Structure
  • File header parsing
  • Workbook globals
  • Sheet information
  • Format definitions
  • Font tables
Cell Types
  • Label cells
  • Number cells
  • Formula cells
  • Blank cells
  • Error cells
  • Boolean cells

Usage Examples

Basic File Reading

public async Task<IDataSet> ReadXlsFile(Stream stream)
{
    var reader = new ExcelBinaryReader();
    reader.Initialize(stream);
    
    var dataSet = new DataSet();
    while (reader.Read())
    {
        // Process rows
        for (int i = 0; i < reader.FieldCount; i++)
        {
            var value = reader.GetValue(i);
            // Handle cell value
        }
    }
    
    return dataSet;
}

Configuring Reader Options

var reader = new ExcelBinaryReader(new ReadOption
{
    IsFirstRowAsColumnNames = true,
    ConvertOADates = true
});

Reading Multiple Sheets

public DataSet ReadAllSheets(Stream stream)
{
    using var reader = new ExcelBinaryReader();
    reader.Initialize(stream);
    
    var dataSet = new DataSet();
    do
    {
        var table = new DataTable(reader.Name);
        // Read sheet data into table
        dataSet.Tables.Add(table);
    } while (reader.NextResult());
    
    return dataSet;
}

Advanced Features

Shared String Handling

private void HandleSharedStrings(XlsBiffSST sst)
{
    // SST (Shared String Table) processing
    foreach (var str in sst.StringList)
    {
        // Process shared string
    }
}

Format Conversion

private object ConvertCellValue(XlsBiffRecord cell, ushort format)
{
    // Handle various Excel formats
    switch (format)
    {
        case FormatType.Date:
            return TryConvertOADateTime(cell.Value);
        case FormatType.Number:
            return ConvertNumber(cell.Value);
        // ... other formats
    }
}

BIFF Record Types

Core Records

  • BOF (Beginning of File)
  • EOF (End of File)
  • BOUNDSHEET (Worksheet Information)
  • SST (Shared String Table)
  • FORMAT (Number Format)
  • XF (Extended Format)

Cell Records

  • LABEL (String Cell)
  • NUMBER (Numeric Cell)
  • FORMULA (Formula Cell)
  • BLANK (Empty Cell)
  • MULBLANK (Multiple Empty Cells)
  • RK (RK Number Cell)

Best Practices

  1. Memory Management

    • Use streaming for large files
    • Dispose readers properly
    • Handle large string tables efficiently
  2. Format Handling

    • Validate cell formats
    • Handle date conversions properly
    • Support custom number formats
  3. Error Handling

    • Check file corruption
    • Handle formula errors
    • Validate record sequences
  4. Performance

    • Use appropriate buffer sizes
    • Cache shared strings
    • Optimize cell access

Integration

With Base Excel Reader

public class BinaryFormatReader : ExcelDataSetReaderBase
{
    protected override IExcelDataReader GetExcelDataReader(Stream stream)
    {
        var reader = new ExcelBinaryReader();
        reader.Initialize(stream);
        return reader;
    }
}

With Message Hub

services.AddMessageHub(hub => hub
    .ConfigureServices(services => services
        .AddSingleton<IExcelReaderFactory>(provider => 
            new ExcelReaderFactory())
        .AddTransient<IDataSetReader, BinaryFormatReader>()
    )
);

Error Handling

The library provides detailed error information for:

  • Invalid file formats
  • Corrupted records
  • Unsupported features
  • Formula errors
  • Format conversion issues
  • MeshWeaver.DataSetReader.Excel - Base Excel reader framework
  • MeshWeaver.DataSetReader.Excel.OpenXmlFormat - Modern Excel format implementation
  • MeshWeaver.DataStructures - Core data structures
Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on MeshWeaver.DataSetReader.Excel.BinaryFormat:

Package Downloads
MeshWeaver.DataSetReader.Excel

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.0.3 467 3/24/2025
2.0.2 441 3/24/2025
2.0.1 96 3/21/2025
2.0.0 130 3/20/2025
2.0.0-preview3 82 2/28/2025
2.0.0-Preview2 87 2/10/2025
2.0.0-preview1 85 1/6/2025
1.0.1 131 10/8/2024
1.0.0 108 10/8/2024