Expand description
Rust spreadsheet processing with bounded streaming XLSX reads.
Reads include sparse scalars, bounded plain/rich strings, numeric and ISO dates, shared style catalogs and normal formulas. Sequential creation shares the core models. Other spreadsheet features remain planned; unsupported selected cells fail loudly.
use crabxl::{AccessPattern, MemoryPolicy, ReadData, WorkbookReader};
let mut workbook = WorkbookReader::open("numbers.xlsx")?;
let output = workbook.read_with_policy(
"Sheet", AccessPattern::RepeatedAccess, MemoryPolicy::default(),
)?;
println!("{:?}", output.decision);
match output.data {
ReadData::Materialized(sheet) => println!("{} rows", sheet.rows.len()),
ReadData::Streaming(mut rows) => while let Some(row) = rows.next_row()? {
println!("{:?}", row.index);
},
}Structs§
- Active
View Selection - Result of serializing a requested view index against sheet visibility.
- Adaptive
Read - An automatically selected read strategy and its inspectable diagnostics.
- Alignment
- Cell alignment overrides with absent values retained.
- Argb
Literal - Compact validated ARGB spelling, without allocating an owned color string.
- Auto
Memory - Automatic budget controls. These tune an operation, not total process RSS.
- Border
- Complete border components, including internal and directional edges.
- Border
Side - One optional border edge; absence and an empty edge remain distinct.
- Cell
- A present cell with its actual coordinate.
- Cell
Address - A validated cell position, independent of any workbook.
- Cell
Error - A literal spreadsheet error, separate from a library I/O/parser error. Unknown future error tokens remain readable without losing their spelling.
- Cell
Format - A format record referring to workbook component tables.
- Cell
Range - A validated finite rectangle, including both end coordinates.
- Cell
Style - Complete appearance components for registering a new shared cell format. Imported component/base-format IDs and named-style metadata live in StyleCatalog.
- Cell
Text - Owned literal text. Indirection keeps common numeric cells compact.
- Color
- Color identity and optional tint without eager RGB conversion.
- Column
Dimension - Sparse worksheet dimension metadata and shared appearance identities. Explicit properties for one inclusive worksheet column interval.
- Column
Index - A validated zero-based worksheet column.
- Data
Table Options - What-if input layout and optional source flags.
- Differential
Style - Sparse appearance overrides; absent components do not install cell defaults.
- Edit
Limits - Limits for one explicitly materialized editable sheet.
- Editor
Options - Budgets for a lazy package editor and its owned value overlays.
- Error
- A spreadsheet error retaining the affected part, cell, and underlying cause. Details are allocated only on failure, keeping successful Result values small.
- Exact
Integer - An exact signed decimal integer exceeding the reader’s i64 fast path.
- Excel
Date Time - Exact finite XLSX serial and its interpretation. No timezone is implied. Serial 60 in the Windows epoch is retained as Excel’s fictitious leap day; converting that value to another calendar epoch is rejected.
- Formula
- An expression with an optional typed cache and structured encoding metadata; no calculation engine or fabricated cache is implied.
- Formula
Annotations - Read-side cell/value metadata references attached to a formula. Literal source indices are retained independently of expression and cache. Their metadata part graphs are not interpreted or recreated by this model.
- Formula
Flag - Optional boolean meaning plus original spelling for public properties which the pinned reference exposes as source strings.
- Formula
Flags - Optional common calculation hints; no calculation engine is implied.
- Formula
Metadata - Structured formula metadata; optional fields retain absence rather than installing flags/ranges or fabricated cached results.
- Formula
Reference - A literal formula reference or explicitly validated worksheet bounds. Literal spelling is retained without imposing geometry on public properties.
- Formula
Token - A token borrowing its source spelling instead of allocating a string.
- Gradient
Fill - Full gradient fill rather than only upstream’s degree/stops subset.
- Gradient
Stop - Color at a gradient position.
- Hyperlink
- Resolved hyperlink properties; package relationship IDs are source hints. The owner coordinate belongs to the worksheet; an optional declaration reference preserves independently mutable public metadata.
- Hyperlink
Output - A declaration and its planned worksheet-local output relationship identity. The projection borrows canonical payloads and never expands covered cells.
- Hyperlinks
- Sparse point links with logarithmic lookup and constant-time byte accounting. Range metadata remains compact; covered coordinates borrow the same payload.
- Load
Options - Managed policy for a source-backed canonical workbook bank.
- Loaded
Workbook - Owns a seekable original package and the canonical workbook bank. Source styles transfer into the bank without cloning; only date classifications stay in the reader. Sheets decode lazily into independently bounded temporary models before a stable-ID commit. This is explicit editable-model loading, not a streaming row mode or a whole-process RSS cap.
- Memory
Allowance - Runtime-independent diagnostics for a managed operation allowance. Existing catalogs, dependency allocations and caller data are additional; this is a snapshot of availability, not a reservation or hard RSS ceiling.
- Merged
Cell Range - A finite merged rectangle and its shared edge/interior appearances. No covered cell objects are allocated. The owning coordinator prepares styles before registering geometry and retains the anchor’s physical value.
- Merged
Range Iter - Allocation-free traversal of indexed merged intervals.
- Merged
Ranges - Bounded sparse merge declarations in registration order.
- Named
Style - Named-style metadata retaining its base-format identity.
- Named
Style Options - Optional metadata for a newly registered named appearance.
- Number
Format - A declared number-format code without dense allocation from its numeric ID.
- Owned
Worksheets - Consuming sheet iterator backed by the workbook’s original entry allocation.
- Page
Break - An explicit page break, stored sparsely without expanding row/column ranges.
- Page
Margins - Six page margins in inches; finite negative descriptor values are retained.
- Page
Setup - Optional baseline paper/scaling/printer settings; integer source values use i64.
- Pane
- Split/frozen viewport. Literal cell spelling is not eagerly interpreted as geometry.
- Paper
Dimension - A literal paper dimension validated against the baseline public prefix pattern. Trailing source spelling is retained, matching the reference descriptor.
- Part
Info - Owned original-part inventory; content is not loaded into RAM.
- Pattern
Fill - Optional fill pattern and colors.
- Phonetic
Properties - Phonetic rendering settings; font identity belongs to the workbook font catalog.
- Phonetic
Run - Pronunciation text attached to a source character range.
- Print
Options - Optional print flags; explicit false remains distinct from absent.
- Print
Settings - Canonical printing metadata. Absence of this entire model costs no sheet allocation.
- Protection
- Cell protection overrides, separate from sheet protection activation.
- Read
Decision - Observable diagnostics for an automatic read operation.
- Read
Options - Projection performed before expensive cell-value decoding.
- Resource
Limits - Limits for archive metadata, XML events, rows, and owned batches.
- Rich
Text - Owned rich text without a redundant flattened-string allocation.
- Rich
Text Run - A contiguous run; None means ordinary text with no explicit run properties.
- Row
- An owned sparse row. Missing columns are not expanded into empty cells.
- RowBatch
- An owned, bounded collection of rows.
- RowDimension
- Sparse worksheet dimension metadata and shared appearance identities. Explicit properties for one worksheet row, independent of its cells.
- RowIndex
- A validated zero-based worksheet row.
- Rows
- A bounded, sparse worksheet row stream borrowing its workbook source.
- RunFont
- Optional run font overrides. Absent properties retain inheritance; explicit false properties must not be confused with absent ones.
- Save
Options - Controls CRC validation during copying. Rewritten XML is always parsed to EOF.
- Save
Stats - Per-save part counts and XML rewrite bytes. No worksheet temp files are used.
- Selection
- One focused cell/range selection; missing properties remain distinct from defaults.
- Shared
Formula Stats - Diagnostics for worksheet-local dependency work, separate from decoded cells.
- Shared
String Options - Shared-string component limits. Returned rows, archive metadata and dependencies are additional. These settings do not impose a hard process RSS limit.
- Shared
String Stats - Current shared-string component diagnostics, excluding returned owned values.
- Sheet
Data - An explicitly materialized scalar worksheet snapshot.
- Sheet
Dimensions - Sparse worksheet dimension metadata and shared appearance identities. Sparse canonical row/column metadata. Capacities participate in the owner cap.
- SheetId
- Opaque runtime sheet identity. It survives reorder/rename and cannot alias removed sheets or sheets in another workbook. It is not a persisted OOXML ID.
- Sheet
Info - One worksheet catalog entry, without loaded worksheet cells.
- Sheet
View - Complete baseline worksheet view attributes, panes and selections.
- Sheet
Views - Source-ordered worksheet views. No cells or dense ranges are retained here.
- Style
Catalog - Shared imported style catalog. Original indices remain stable; declarations never reserve from an advertised count. Number-format classification is cached by canonical records; format codecs build bounded indexed cell lookups.
- StyleId
- A workbook-local index into the shared cell-format table.
- Style
Integer - Exact style integer with an allocation-free signed i64 fast path. Large decimal identities are owned and never converted through floating point.
- Style
Limits - Managed retained style storage and actual per-table record allowances.
- Style
Registry - One canonical catalog plus collision-checked indices. Styles share components, not whole appearance clones. Catalog access is borrowed and immutable so numeric IDs and deduplication indices cannot become stale.
- Style
View - Borrowed appearance components for an existing cell-format identity. Source application/base-style flags remain accessible through format. This view installs no inferred defaults or locale-specific format codes.
- Table
Style - Named custom table/pivot style with source-ordered elements.
- Table
Style Catalog - Default style names and named custom definitions; advertised counts are ignored.
- Table
Style Element - One table/pivot region’s differential formatting reference.
- Temporal
Style Ids - Canonical workbook-local temporal presets. IDs are resolved from each source catalog rather than assuming that imported records occupy 1..=4.
- Theme
- Exact theme-part bytes, including unknown drawing sections and typeface names. This core container does not interpret or validate an XML serialization.
- Theme
Catalog - Typed read-side palette and font scheme. Original opaque theme bytes remain separately available; this is not a drawing/effect graph or editing model.
- Theme
Font Collection - Major or minor theme font collection.
- Theme
Script Font - Supplemental typeface for a script, in document order.
- Theme
Typeface - Typeface properties in a theme font collection. Empty typeface names are meaningful and remain distinct from absent elements.
- Workbook
- I/O-free owned workbook. Unknown original parts belong to the separate lazy XLSX editor; this model does not imply loaded-package structural preservation. Cells/styles/formulas use the same shared core representation.
- Workbook
Editor - Owns the original source and a bounded overlay, keeping unknown XML/binary parts on their original source. save borrows self, so repeated saves retain images/macros and never consume the original or the pending edits.
- Workbook
Limits - Aggregate allowances for an explicitly owned workbook and its sheet bank.
- Workbook
Parts - Ownership transfer for exporting a canonical workbook without catalog snapshots.
- Workbook
Reader - Owns a seekable ZIP source and a small sheet catalog, not worksheet cells.
- Workbook
Writer - One-shot XLSX writer using bounded rows and owned temporary worksheets.
- Worksheet
- Sparse owned cell model. Structural edits move coordinates and preserve formulas verbatim; reference translation and feature graphs are separate. This is distinct from a lazy original-file editor and opaque preservation.
- Worksheet
Editor - Aggregate-budget mutation facade. Dropping restores the sheet’s configured personal ceiling; the workbook recomputes remaining aggregate space on each new borrow. Caller-owned removed values are outside the retained budget.
- Worksheet
Range - A worksheet-local range without allocating its covered cells. Absolute markers are accepted when parsing; geometry does not retain them. Sheet qualification belongs to the owning feature, rather than this type.
- Write
Options - Configurable resource limits for sequential worksheet spooling. These bound managed buffers/metadata and temporary XML, not process RSS.
- Write
Stats - Progress including logical temporary bytes, which also count unflushed XML.
Enums§
- Access
Pattern - Intended access pattern, used to choose a useful allocation strategy.
- Border
Line - Cell border line style.
- Calculation
Chain Policy - Policy for the derived calculation order after values or formulas change.
- Cell
Metadata Read Policy - Treatment of opaque cell/value metadata references during value projection.
- Cell
Value - Values supported by the current scalar reader.
- Color
Kind - Workbook-independent color reference. Theme/indexed colors retain identity.
- Date
Epoch - Workbook serial-date origin.
- Date
Kind - Interpretation of a date/time serial value.
- Date
Read Policy - How numeric date-formatted values outside the reference calendar range are read.
- Decision
Reason - The reason for the final automatic strategy.
- Error
Kind - Stable categories suitable for matching in Rust or language adapters.
- Fill
- Shared fill model used by both imported catalogs and new styles.
- Fill
Pattern - Pattern fill style.
- Font
Scheme - Theme font scheme.
- Formula
Read Policy - Validation of worksheet-local shared formula groups.
- Formula
Type - Formula encoding category; shared indices are local to one worksheet.
- Formula
Write Policy - Serialization of optional formula flags and empty data-table inputs.
- Gradient
Kind - Gradient geometry.
- Horizontal
Alignment - Horizontal cell alignment.
- Memory
Policy - Shared managed-memory policy for reading and editable operations.
- Memory
Source - Where effective available-memory information came from.
- NonFinite
Write Policy - XLSX serialization of nonfinite numeric values and formula caches.
- Page
Order - page traversal order
- Page
Orientation - page orientation
- Pane
Position - A visible pane’s position relative to worksheet splits.
- Pane
State - Split or frozen viewport behavior.
- Print
Settings Change - An owned replacement of one printing component, leaving unrelated vectors in place. Incoming payloads are moved on success and dropped on failure; existing data is retained.
- Printed
Comments - printed comment placement
- Printed
Errors - printed error representation
- Read
Data - Data returned by an automatic numeric read operation.
- Read
Mode - A selected numeric read strategy.
- Shared
Formula Index - Source shared-formula group identity. Missing and empty identifiers are distinct; noncanonical spelling is not normalized into another group.
- Shared
String Storage - Placement of decoded shared strings and their index.
- Sheet
Kind - The kind of a workbook sheet.
- Sheet
Visibility - Workbook catalog visibility of a worksheet or opaque sheet placeholder.
- Style
Component - One explicit appearance replacement, retaining all unrelated format fields. Large components are moved into the shared registry rather than cloned.
- Style
Write Policy - Serialization of alignment attributes with zero/false values.
- Table
Style Region - Table/pivot formatting region from the pinned public schema.
- Text
Vertical Alignment - Run baseline position.
- Theme
Color - A DrawingML palette color, preserving system-color identity separately from its portable last-known RGB value. Color transforms require explicit support.
- Theme
Write Policy - Theme emission policy for newly created packages.
- Token
Kind - Lexical role of a formula token.
- Token
Subtype - Additional operand or boundary meaning.
- Underline
- Underline shape, distinct from a missing run property.
- Vertical
Alignment - Vertical cell alignment.
- View
Mode - Worksheet display mode, separate from printing configuration.
Constants§
- BUILTIN_
NUMBER_ FORMATS - Known portable built-in format identities and reference-compatible spelling. Locale-specific reserved identities are deliberately not fabricated.
- MAX_
COLUMNS - Maximum worksheet columns in XLSX.
- MAX_
ROWS - Maximum worksheet rows in XLSX.
Functions§
- builtin_
number_ format - Borrow a known built-in format without allocating a table or format string.
- builtin_
number_ format_ id - Find a portable built-in identity by its exact baseline spelling. Different locale spellings remain explicit custom format codes.
- classify_
formula_ operand - Classify a public operand literal without evaluating or validating an expression.
- classify_
number_ format - Classify an Excel format’s first section without allocation. Quoted/escaped literals and elapsed-time brackets retain the shared codec rules.
- formula_
position - Parse a formula tool’s one-based origin/destination. Unlike a physical cell, its row can extend beyond XLSX worksheet limits, matching baseline utilities. Column labels are limited to three letters; row labels must fit u64.
- memory_
allowance - Compute an allowance using the reader/editor’s shared availability policy. Reserves the configured parser components. Catalogs, dependencies, allocator overhead and caller-retained data are additional; this is not a hard RSS cap.
- normalize_
active_ view - Normalize a deferred view without allocating a visible-sheet vector. Visible targets retain the original signed index. Otherwise select from the reference’s sliced visible-sheet list; no following candidate omits activeTab.
- parse_
iso8601 - Parse pinned public ISO prefix behavior without reading reference source. Empty text is absent. Recognized calendar/clock prefixes ignore trailing text, including zone suffixes, as the compatibility baseline does. Only hour/minute/second elapsed durations are supported; no day/year notation.
- read_
rich_ text - Decode one namespaced
isorsielement with explicit resource limits. Complete input consumption rejects extra roots and malformed trailing XML. - resolve_
sheet_ index - Resolve a signed, possibly relative display index without changing its spelling. Out-of-range indexes represent an unselected view.
- tokenize_
formula - Tokenize with a joint byte cap on source length and token/stack work capacity. Source input is borrowed. Unclosed function/group openers remain observable, matching the reference lexer; unmatched closers return a typed error.
- translate_
axis - Translate one validated positive row or three-letter column label. Absolute labels retain their spelling; relative labels use canonical output.
- translate_
expression - Shift relative A1 references in a bare or equals-prefixed expression. Absolute axes, sheet qualifiers, quoted strings and structured-reference brackets retain their context. Whole-row/column ranges do not expand cells. Output capacity is byte-bounded; input and caller data are additional. This is a translation scanner, not a complete formula tokenizer/parser. Dynamic spill syntax and unclosed quotes/brackets are rejected explicitly. Reference row labels beyond seven digits retain baseline named-range behavior.
- visit_
owned_ hyperlink_ ids - Visit ordinary owned-package identities in the exact shared writer order. The callback may retain selected identifiers; no persistent table is built.
- write_
rich_ text - Write a namespaced inline rich value using the canonical format codec.
Type Aliases§
- Font
- Shared optional font properties, identical to rich-run overrides. Missing properties retain their identity rather than installing defaults.
- Formula
Range - Existing name retained for callers constructing validated formula ranges.
- Result
- A result with a context-rich spreadsheet error.