Expand description
Bounded XLSX/XLSM reading, deterministic calculation, editing, and writing.
CellRune separates source data from recalculated results:
read_xlsx_path,read_xlsx_bytes, orread_xlsxcreates an immutableWorkbookSnapshot.calculate_workbookcreates a separate ownedCalculationSnapshotwithout changing the source workbook or its saved XLSX results.- Each formula result is either a typed
CalculationCellResult::Valueor a structuredCalculationCellResult::Unavailableissue.
§Quick start
use cellrune::{
CalculationCellResult, CalculationOptions, FiniteNumber, ReadOptions, calculate_workbook,
read_xlsx_path,
};
let workbook = read_xlsx_path("input.xlsx", ReadOptions::default())?;
let options = CalculationOptions::default()
.with_today_serial(FiniteNumber::new(46_225.0)?);
let calculation = calculate_workbook(&workbook, options);
if let Some(sheet) = workbook.sheet_by_name("Sheet1") {
let source_cell = sheet.cell_by_a1("A1")?;
let _ = source_cell;
}
for (cell, result) in calculation.cells() {
match result {
CalculationCellResult::Value(value) => println!("{cell:?}: {value:?}"),
CalculationCellResult::Unavailable(issue) => {
eprintln!("{cell:?}: {}", issue.code().as_str());
}
}
}§Failure model
CellRune keeps failures at their owning boundary:
XlsxReadErrormeans no trustworthy workbook snapshot could be produced. ItsXlsxReadError::codeis stable and machine-readable.Diagnosticrecords a compatibility caveat on a successfully read workbook.CalculationIssueexplains why one formula has no recalculated value. Unsupported engine capabilities are not converted into Excel errors and cannot be hidden byIFERROR.CellValue::Errorrepresents an actual spreadsheet error value.ValidationErrorrejects invalid caller-provided model values and addresses.
Reading never executes macros or follows external links. Calculation is explicit and does not mutate or implicitly write a workbook. Recalculated result materialization is a separate explicit operation on package-backed documents.
§Numeric contract
Calculated numbers are not guaranteed to be bit-identical to Excel’s.
docs/NUMERICS.md
records every known deliberate difference, the Excel build each statement was
measured against, and which function families remain unmeasured. Compare results with a
tolerance rather than for equality.
Two behaviors are selectable through CalculationOptions, and both default to matching
Excel rather than to what releases up to 0.1.2 did:
ArithmeticSemanticsdecides whether Excel’s narrow near-zero correction is applied to a decimal/rational cancellation, or every IEEE-754 residue is preserved.FinancialSolverSemanticsdecides whetherIRR,XIRR, andRATEstop at the iteration budget Microsoft documents, or search longer and return values where Excel reports#NUM!.
Select ArithmeticSemantics::Ieee754 and FinancialSolverSemantics::ExtendedSearch to
restore the 0.1.2 behavior.
Structs§
- Calculation
Cell Id - Stable identity of a formula cell within one workbook snapshot.
- Calculation
Delta - Bounded, deterministically ordered result changes from one installed calculation.
- Calculation
Delta Cell - One changed direct or materialized calculation result.
- Calculation
Delta Page - One cursor page of complete, individually bounded calculation deltas.
- Calculation
Hints - Calculation hints read from workbook metadata without triggering calculation.
- Calculation
Issue - A structured formula calculation issue with optional source-specific detail.
- Calculation
Limits - Resource limits applied while formulas are parsed, scheduled, and evaluated.
- Calculation
Options - Deterministic inputs for volatile calculation behavior.
- Calculation
Snapshot - Immutable formula results, separate from source literals and saved XLSX values.
- Calculation
Target - A rectangular set of requested cells on one sheet.
- Cancellation
Token - Thread-safe cooperative cancellation signal for one bounded operation.
- Cell
- A sparse cell with a validated address and content.
- Cell
Address - A validated cell address ordered in row-major order.
- Cell
Phonetics - Borrowed effective phonetic metadata for one cell.
- Cell
Range - A non-empty rectangular range with validated, inclusive endpoints.
- Column
- A validated, one-based Excel column index.
- Column
Phonetic Visibility - One source column range carrying a default phonetic visibility flag.
- Completed
Calculation - A calculated but not yet installed session result.
- Completed
Target Calculation - A partial result awaiting source-state validation, never a complete calculation snapshot.
- Completed
Workbook Transaction - A fully calculated transaction that can be inspected, installed once, or discarded.
- Defined
Name - A validated workbook or sheet-local name formula.
- Defined
Name Analysis Error - Execution failure returned separately from a semantic analysis result.
- Defined
Name Analysis Options - Bounded options for a defined-name inspection.
- Defined
Name Analysis Options Error - Error returned when a defined-name analysis limit is zero.
- Defined
Name External Reference - Typed detail retained from an external-workbook reference node.
- Defined
Name Sheet Span - Stable workbook-order identity of a continuous 3-D sheet span.
- Diagnostic
- A compatibility or capability diagnostic, separate from Excel values.
- Diagnostic
Code - A stable machine-readable diagnostic code.
- Document
Presentation - XLSX presentation metadata kept separate from calculation semantics.
- Edit
Batch - An ordered collection of workbook changes committed atomically.
- Edit
Receipt - Result of committing one atomic edit batch.
- Finite
Number - A finite IEEE-754 number accepted at the workbook boundary.
- Formula
Capability Entry - Capability status for one formula cell.
- Formula
Capability Report - Deterministically ordered capability report for all formula cells.
- Formula
Cell - A formula cell before recalculation.
- Formula
Text - Formula text normalized to the XLSX storage form without a leading
=. - Frozen
Pane - A validated frozen-pane position expressed as fixed row and column counts.
- Function
Catalog Entry - One deterministic entry in the supported function catalog.
- Function
Usage Entry - Aggregated use of one normalized function name in a workbook.
- Function
Usage Report - Workbook-level function demand report for prioritizing compatibility work.
- Input
Hash - A SHA-256 digest associated with an input.
- Materialized
Calculation Cell - One typed or unavailable result in the complete calculation materialization view.
- Number
Format - Number-format metadata attached to a cell while preserving its raw numeric value.
- Open
Options - Options for opening a package-backed writable workbook document.
- Output
Hash - A SHA-256 digest associated with verified output bytes.
- Package
Summary - Safely discovered package parts before workbook values are interpreted.
- Phonetic
Properties - Display properties attached to a phonetic string item.
- Phonetic
Run - One phonetic string displayed over a range of literal base text.
- Phonetic
Text Range - A half-open range in zero-based UTF-16 code units over the base cell text.
- Phonetic
Write Options - Visibility and display properties used when authoring phonetic text.
- Prepared
Calculation - An immutable calculation job safe to execute outside a session lock.
- Prepared
Edit Batch - An atomic workbook edit batch staged for guarded installation.
- Prepared
Target Calculation - An immutable partial calculation job that owns its source snapshot.
- Prepared
Workbook Transaction - An immutable off-lock job containing one captured base and validated edit candidate.
- Provenance
- Deterministic producer and input identity metadata.
- Provider
Identity - The component that produced a snapshot or calculation.
- Read
Limits - Resource limits applied before workbook semantics are interpreted.
- Read
Options - Read behavior and resource budgets for XLSX input.
- Recalculated
Workbook - Verified in-memory XLSX or XLSM output and its write report.
- Recalculation
Write Options - Options for materializing a calculation into an existing XLSX or XLSM package.
- Resolved
Phonetic Run - One phonetic run resolved into byte offsets over concrete base text.
- Row
- A validated, one-based Excel row index.
- Saved
Result Issue - Why a stored formula result could not be interpreted.
- Session
Error - Structured stateful-session error with a stable code and optional detail.
- Session
Limits - Stateful-session resource limits independent of formula-kernel limits.
- Sheet
- A sparse, format-neutral worksheet.
- SheetId
- A validated, non-zero workbook-local sheet identifier.
- Sheet
Name - A validated sheet name with its original spelling preserved.
- Source
Id - An opaque identifier for a source unit such as a package part.
- Source
Location - A source-linked position with invariants enforced by dedicated constructors.
- Table
- An Excel table (ListObject) definition owned by its worksheet.
- Table
Auto Filter - Typed auto-filter metadata attached to one table.
- Table
Color Filter - A differential-format color filter.
- Table
Column - One table column with the stable XLSX column identifier.
- Table
Column Id - A validated, non-zero identifier for one column within an Excel table.
- Table
Column Name - A validated table-column name for authoring operations.
- Table
Custom Filter - One comparison used by a custom table filter.
- Table
Custom Filters - Custom comparisons for one filter column.
- Table
Date Group Item - One grouped calendar value selected by a table auto-filter.
- Table
Date Time Value - A validated OOXML
xsd:dateTimetoken with its source spelling retained. - Table
Dynamic Filter - A dynamic date or numeric filter.
- Table
Filter Column - One zero-based column selector and its typed filtering rule.
- Table
Formula - A calculated-column or totals-row formula stored in a table definition.
- Table
Icon Filter - An icon-set filter.
- TableId
- A validated, non-zero workbook-local Excel table identifier.
- Table
Name - A table name with its original spelling preserved.
- Table
Numeric Value - A validated OOXML double token with its source spelling retained.
- Table
Sort Condition - One typed sort condition within a table sort state.
- Table
Sort State - Sort metadata attached to a table or auto-filter definition.
- Table
Style Info - The style flags attached to one table.
- Table
TopFilter - A top/bottom count or percentage filter.
- Table
Value Filters - Literal and grouped-date selections for one filter column.
- Target
Calculation Error - A targeted-calculation request failed without changing workbook state.
- Target
Calculation Limits - Request-wide limits independent of per-formula calculation limits.
- Target
Calculation Result - Immutable values for explicitly requested cells, never a complete workbook calculation.
- Transaction
Affected Formula - One formula in the bounded semantic impact report.
- Transaction
Impact Page - One complete item-bounded transaction detail page.
- Transaction
Install Result Change - One exact result change that installation will append to calculation history.
- Transaction
Issue Change - One exact base-to-candidate calculation issue difference.
- Transaction
Page Cursor - Opaque report-local cursor for one transaction detail section.
- Transaction
Result Change - One exact base-to-candidate materialized result change.
- Workbook
Calculation Session - Stateful workbook editor and persistent calculation engine.
- Workbook
Draft - An owned, mutable workbook editing session with monotonic semantic revisions.
- Workbook
Fingerprint - A versioned, history-independent digest of workbook semantics.
- Workbook
Snapshot - An immutable workbook snapshot with deterministic sheet lookup and order.
- Workbook
Source - Non-sensitive source metadata retained by the snapshot.
- Workbook
Transaction Receipt - Exact edit and calculation receipts returned by a successful transaction install.
- Workbook
Transaction Report - Complete bounded summary and pageable details for one calculated transaction.
- Write
Limits - Resource budgets for XLSX package generation and verification.
- Write
Options - XLSX output behavior and resource budgets.
- Write
Provenance - Exact calculation and source identity recorded for a completed workbook write.
- Write
Report - Structured outcome of materializing a calculation into a preserved workbook package.
- Xlsx
Document - An immutable workbook snapshot paired with its exact preserved XLSX or XLSM package.
- Xlsx
Read Error - A source-linked XLSX read failure with a stable error code.
- Xlsx
Write Error - A source-linked XLSX write failure with a stable error code.
Enums§
- Apply
Changes Error - Error boundary for atomic edit validation and state conflicts.
- Arithmetic
Semantics - How arithmetic treats Excel’s narrow near-zero cancellation case.
- Calculation
Cell Result - Result of calculating one formula cell.
- Calculation
Decision Reason - Deterministic explanation for the selected calculation schedule.
- Calculation
Execution Mode - Actual schedule used by one installed calculation.
- Calculation
Issue Code - Stable machine-readable reason that a formula was not calculated.
- Calculation
Mode - Workbook calculation mode metadata.
- Calculation
Options Error - Invalid caller-provided calculation configuration.
- Cell
Content - The mutually exclusive content stored at a sparse cell address.
- Cell
Value - A literal or saved cell value.
- Date
System - Excel’s serial date epoch selection.
- Defined
Name Analysis - Typed analysis of one workbook or sheet-local defined name.
- Defined
Name Analysis Error Kind - Stable execution-failure category for a defined-name query.
- Defined
Name Analysis Limit Kind - Resource unit enforced by defined-name analysis.
- Defined
Name Dynamic Kind - Dynamic reference construct that determines a name’s reference shape at calculation time.
- Defined
Name External Target Kind - Typed target category of an external-workbook reference.
- Defined
Name Invalid Reason - Reason a reachable defined-name formula is invalid against the immutable workbook snapshot.
- Defined
Name Reference Area - One area in an ordered non-rectangular defined-name reference.
- Defined
Name Scope - Visibility scope of a workbook defined name.
- Defined
Name Unsupported Reason - Reason a valid formula cannot be represented as static reference geometry.
- Diagnostic
Severity - Severity independent of Excel cell errors.
- Excel
Error - An error value stored by a spreadsheet cell.
- Financial
Solver Semantics - How the iterative financial solvers decide they have failed.
- Formula
Capability - Static grammar and function-surface capability for one formula.
- Formula
Dialect - The formula grammar stored in a workbook snapshot.
- Formula
Metadata - Formula container metadata preserved independently of formula text.
- Function
Support - Whether a function name found in a workbook is implemented by the current engine.
- Install
Delta Basis Reason - Why the installed-calculation delta has a different comparison basis than the preview.
- Materialized
Result Origin - Why a calculated cell is present in the complete materialization view.
- Number
Format Kind - Semantic category inferred from an XLSX number format without changing the stored value.
- Phonetic
Alignment - Horizontal alignment of phonetic text over its base text.
- Phonetic
Type - Character conversion requested for displayed phonetic text.
- Read
Options Error - Invalid caller-provided reader configuration.
- Recalculation
Mode - Caller-selected recalculation policy.
- Recalculation
Write Policy - Policy for formulas that do not have a current materialized calculation result.
- Saved
Result - A formula’s stored result, kept distinct from a blank result.
- Session
Error Code - Stable machine-readable failure produced by a stateful calculation session.
- Shared
Formula Role - Whether a shared formula cell defines or follows its group.
- Sheet
Visibility - Sheet visibility as represented by
SpreadsheetML. - Table
Calendar Type - Calendar systems accepted by OOXML table value filters.
- Table
Custom Filter Operator - Comparison operators accepted by a custom table filter.
- Table
Date Time Grouping - Calendar granularity used by one grouped-date filter item.
- Table
Dynamic Filter Type - Dynamic filter categories defined by OOXML.
- Table
Filter Criteria - The typed filtering rule attached to one auto-filter column.
- Table
Filter Item - One value or grouped date selected by a table auto-filter.
- Table
Icon Set - Built-in icon sets accepted by OOXML table filters and sorts.
- Table
Sort By - Value source used by an OOXML sort condition.
- Table
Sort Method - Sort collation method declared by OOXML.
- Table
Type - The data source represented by an Excel table definition.
- Target
Calculation Error Code - Stable request failure for targeted calculation.
- Totals
RowFunction - The totals-row aggregation declared for one table column.
- Transaction
Detail Item - One item from a transaction detail page.
- Transaction
Detail Section - A transaction report detail section.
- Transaction
Impact Cause - Why one formula appears in the affected-formula section.
- Transaction
Impact Coverage - Completeness of the semantic affected-formula set.
- Transaction
Issue Change Kind - Classification of one exact calculation issue difference.
- Validation
Error - A violation of a format-neutral workbook invariant.
- Validation
Error Code - Stable machine-readable code for a format-neutral validation failure.
- Workbook
Change - One validated workbook mutation in an atomic
EditBatch. - Workbook
Source Kind - The caller-facing input adapter that supplied workbook bytes.
- Write
Options Error - Invalid caller-provided writer configuration.
- Xlsx
Document Kind - Open XML spreadsheet package kind retained by a writable document.
- Xlsx
Error Code - Stable machine-readable failure codes for XLSX file errors.
- Xlsx
Write Error Code - Stable machine-readable failure codes for XLSX writing.
Constants§
- EXCEL_
MAX_ COLUMNS - Maximum column supported by an Excel worksheet.
- EXCEL_
MAX_ ROWS - Maximum row supported by an Excel worksheet.
Functions§
- analyze_
defined_ name - Analyzes one defined name with default bounded options.
- analyze_
defined_ name_ cancellable - Analyzes one defined name with explicit options and cooperative cancellation.
- analyze_
defined_ name_ with_ options - Analyzes one defined name with explicit bounded options.
- calculate_
targets - Calculates requested cells and their required precedents without changing the source.
- calculate_
workbook - Calculates formulas without mutating the source snapshot and records runtime issues per cell.
- inspect_
package - Validates package budgets and discovers workbook-related parts without reading cells.
- open_
xlsx_ document - Opens a bounded package-backed workbook from a seekable reader.
- open_
xlsx_ document_ bytes - Opens a bounded package-backed workbook from in-memory XLSX or XLSM bytes.
- open_
xlsx_ document_ path - Opens a bounded package-backed workbook from a filesystem path without retaining the host path.
- read_
xlsx - Reads workbook metadata, sparse literal cells, formulas, and saved results from a bounded XLSX stream.
- read_
xlsx_ bytes - Reads workbook metadata, sparse cells, formulas, and saved results from in-memory XLSX bytes.
- read_
xlsx_ path - Opens and reads an XLSX workbook from a filesystem path without retaining the host path.
- scan_
formula_ capabilities - Scans formula grammar and function-surface support without returning calculated values.
- scan_
formula_ capabilities_ with_ options - Scans formula support under caller-provided deterministic parse, name, and dependency limits.
- scan_
function_ usage - Counts normalized function demand using default calculation limits.
- scan_
function_ usage_ with_ options - Counts normalized function demand using caller-provided calculation limits.
- supported_
function_ catalog - Returns the deterministic catalog of function names implemented by this build.
- write_
preserved_ xlsx_ bytes - Rebuilds an opened package by raw-copying every unchanged ZIP entry.
- write_
recalculated_ xlsx - Writes a fully prepared and verified recalculated package to an output.
- write_
recalculated_ xlsx_ bytes - Materializes a calculation, verifies the completed package, and returns owned archive bytes.
- write_
recalculated_ xlsx_ path - Saves a verified recalculated package to a new path or explicitly replaces the destination.
- write_
xlsx_ draft - Writes a fully prepared draft archive to an output sink.
- write_
xlsx_ draft_ bytes - Calculates materialization output for a draft and returns a verified XLSX or XLSM archive.
- write_
xlsx_ draft_ path - Saves a verified draft package to a new path or explicitly replaces the destination.