Bodu.IO.Biff 0.5.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Bodu.IO.Biff --version 0.5.0
                    
NuGet\Install-Package Bodu.IO.Biff -Version 0.5.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="Bodu.IO.Biff" Version="0.5.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Bodu.IO.Biff" Version="0.5.0" />
                    
Directory.Packages.props
<PackageReference Include="Bodu.IO.Biff" />
                    
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 Bodu.IO.Biff --version 0.5.0
                    
#r "nuget: Bodu.IO.Biff, 0.5.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.
#:package Bodu.IO.Biff@0.5.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Bodu.IO.Biff&version=0.5.0
                    
Install as a Cake Addin
#tool nuget:?package=Bodu.IO.Biff&version=0.5.0
                    
Install as a Cake Tool

Bodu.IO.Biff

API stability — Preview. The public API surface is largely settled but is still being finalized ahead of the 1.0 release and may change; breaking changes can land in a minor version until then.

A low-level codec for the Excel Binary Interchange File Format (BIFF) record streams found inside legacy .xls workbooks, covering BIFF5 and BIFF8.

It understands how BIFF is encoded, not what a workbook means. There is no compound-file container, no workbook or cell model, and no formula evaluation — it frames records, resolves their strings and numbers, and hands you the values. That separation is deliberate: it is the substrate beneath Bodu.Formats.Excel.Binary, in the same relation Bodu.IO.Pst has to Bodu.Formats.Outlook.Pst.

using Bodu.IO.Biff;

// BiffReader is a forward-only ref struct over a span — no allocation per record.
var reader = new BiffReader(workbookStreamBytes);

while (reader.Read())
{
    switch (reader.RecordType)
    {
        case BiffRecordType.Bof:
            BiffBofRecord bof = reader.GetBof();
            Console.WriteLine($"{bof.Version} {bof.SubstreamType}");
            break;

        case BiffRecordType.BoundSheet:
            BiffBoundSheetRecord sheet = reader.GetBoundSheet();
            Console.WriteLine($"{sheet.Name} at 0x{sheet.StreamOffset:X} ({sheet.State})");
            break;

        case BiffRecordType.Number:
            BiffNumberRecord number = reader.GetNumber();
            Console.WriteLine($"({number.Row},{number.Column}) = {number.Value}");
            break;

        // An unknown record is never an error — its identifier and raw payload are still exposed.
        default:
            Process(reader.RecordId, reader.ValueSpan);
            break;
    }
}

Capabilities

  • Forward-only, allocation-free framing. BiffReader is a ref struct over a ReadOnlySpan<byte>. Every record exposes its identifier (RecordId / RecordType), length, start offset, and raw ValueSpan; an unrecognized record is data, never a failure.
  • Resumable across buffers. The (data, isFinalBlock, state) constructor plus CurrentState / BytesConsumed let a caller feed the stream in chunks, so a workbook need not be buffered whole.
  • Version and code page established from the stream itself — BOF sets Version, CODEPAGE sets CodePage — so BIFF5 byte strings decode in the workbook's own encoding rather than a guess.
  • Typed accessors for the common structural and cell records: GetBof, GetBoundSheet, GetDimensions, GetRow, GetNumber, GetRk, GetMulRk, GetLabel, GetLabelSst, GetRString, GetBoolErr, GetBlank, GetMulBlank, GetFormula, GetString, GetXf, GetFormat, GetFont, GetCodePage, GetDateMode, GetFilePass, GetSstHeader — each returning a typed Biff*Record.
  • Shared string table across CONTINUE boundaries. BiffSstReader walks the SST even when a single string is split across records, reporting IsFragmented and exposing GetString / CopyTo.
  • Span-backed text. BiffString is a view over BIFF8 Unicode or BIFF5 code-page text; no string is materialized until you ask for one.
  • RK numbers encode and decode through BiffRk (Decode / TryEncode), including the ×100 and integer-flag variants.
  • Writing. BiffWriter over an IBufferWriter<byte> emits conformant BIFF5 or BIFF8: WriteRecord / WriteContinuedRecord, the BOF/EOF and cell and globals writers, and WriteSst with automatic CONTINUE splitting.
  • Diagnosable failures. BiffFormatException carries the byte Offset; BiffUnsupportedVersionException carries the RawVersion it saw. Encrypted workbooks are identified (FILEPASS / BiffEncryptionType) rather than silently mis-parsed.

Runnable sample

The repository ships an offline, dotnet run-able sample for this package under samples/IO.Biff/.

Out of scope

The compound-file (OLE2) container that holds the Workbook stream — use Bodu.IO.Compound. A workbook or cell object model, number-format application, and formula evaluation — use Bodu.Formats.Excel.Binary, which is built on this package. Decrypting a password-protected workbook is not supported; such a stream is reported, not read.

Part of the Bodu utility library.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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.  net9.0 was computed.  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.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.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 Bodu.IO.Biff:

Package Downloads
Bodu.Formats.Excel.Binary

A narrow, read-only reader for the Excel binary workbook format (.xls): BIFF8 as written by Excel 97-2003 and BIFF5 as written by Excel 5.0/95. Exposes the raw cell values of a worksheet — strings, numbers, booleans, and errors, including the cached result of a formula cell — along with each cell's number format and date-format detection, the workbook date system, each sheet's declared used range, and the workbook document properties. Offers both a streaming cell surface and a materialized, randomly addressable worksheet view, without formula evaluation, styling, or any higher-level interpretation. Built on Bodu.IO.Compound for the container and Bodu.IO.Biff for the record stream.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 53 9/24/2026
0.7.0 111 9/24/2026
0.6.0 66 9/24/2026
0.5.0 72 9/23/2026