Bodu.IO.Biff
0.5.0
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
<PackageReference Include="Bodu.IO.Biff" Version="0.5.0" />
<PackageVersion Include="Bodu.IO.Biff" Version="0.5.0" />
<PackageReference Include="Bodu.IO.Biff" />
paket add Bodu.IO.Biff --version 0.5.0
#r "nuget: Bodu.IO.Biff, 0.5.0"
#:package Bodu.IO.Biff@0.5.0
#addin nuget:?package=Bodu.IO.Biff&version=0.5.0
#tool nuget:?package=Bodu.IO.Biff&version=0.5.0
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.
BiffReaderis aref structover aReadOnlySpan<byte>. Every record exposes its identifier (RecordId/RecordType), length, start offset, and rawValueSpan; an unrecognized record is data, never a failure. - Resumable across buffers. The
(data, isFinalBlock, state)constructor plusCurrentState/BytesConsumedlet a caller feed the stream in chunks, so a workbook need not be buffered whole. - Version and code page established from the stream itself —
BOFsetsVersion,CODEPAGEsetsCodePage— 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 typedBiff*Record. - Shared string table across
CONTINUEboundaries.BiffSstReaderwalks the SST even when a single string is split across records, reportingIsFragmentedand exposingGetString/CopyTo. - Span-backed text.
BiffStringis 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.
BiffWriterover anIBufferWriter<byte>emits conformant BIFF5 or BIFF8:WriteRecord/WriteContinuedRecord, theBOF/EOFand cell and globals writers, andWriteSstwith automaticCONTINUEsplitting. - Diagnosable failures.
BiffFormatExceptioncarries the byteOffset;BiffUnsupportedVersionExceptioncarries theRawVersionit 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 | Versions 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. |
-
net8.0
- Bodu.Core (>= 0.5.0)
- System.Text.Encoding.CodePages (>= 8.0.0)
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.