Skip to main content

Crate xl3_core

Crate xl3_core 

Source
Expand description

xl3-core — pure-Rust XLSX template rendering engine.

Reads an Excel template plus a data workbook, evaluates the XTL expressions inside template cells, and emits a rendered XLSX buffer. This is the same engine that powers the xl3-wasm npm package; it can also be embedded directly in Rust CLIs, Tauri desktop apps, or server-side batch jobs.

§Quick start

use xl3_core::render_from_bytes_to_files;

let template = std::fs::read("template.xlsx").unwrap();
let data = std::fs::read("data.xlsx").unwrap();
let files = render_from_bytes_to_files(&template, &data).unwrap();
std::fs::write(&files[0].filename, &files[0].data).unwrap();

§Pipeline

  1. plan — parse the template workbook + __config__ sheet into a WorkbookPlan of static and expansion rows.
  2. source — read the data workbook into row records.
  3. [render] — walk the plan, evaluating each cell through eval, and emit cells through output.

See the parent repository’s PLAN.md for the broader roadmap.

Re-exports§

pub use errors::is_xtl_error;
pub use errors::XtlError;
pub use introspect::preview;
pub use introspect::preview_bytes;
pub use introspect::read_template_inputs;
pub use introspect::read_template_inputs_bytes;
pub use introspect::InputKind;
pub use introspect::InputSpec;
pub use introspect::PreviewFile;
pub use introspect::PreviewResult;
pub use introspect::PreviewSheet;
pub use introspect::PreviewSource;
pub use manifest::AlignmentSpec;
pub use manifest::ColumnWidth;
pub use manifest::FillPattern;
pub use manifest::FillSpec;
pub use manifest::FontSpec;
pub use manifest::HorizontalAlign;
pub use manifest::StyleManifest;
pub use manifest::StyleSpec;
pub use manifest::VerticalAlign;
pub use output_model::OutputFile;
pub use output_model::XtlWarning;
pub use plan::parse_template;
pub use plan::parse_template_bytes;
pub use plan::CellSource;
pub use plan::RowPlan;
pub use plan::SheetPlan;
pub use plan::WorkbookPlan;
pub use render::render;
pub use render::render_from_bytes_to_files;
pub use render::render_from_bytes_to_files_full;
pub use render::render_from_bytes_to_files_with_inputs;
pub use render::render_to_files;
pub use source::CalamineSourceReader;
pub use source::SourceData;
pub use source::SourceReader;
pub use value::Value;
pub use calamine;
pub use rust_xlsxwriter;

Modules§

directives
Directive parsing.
errors
Stable error-code surface, mirroring xl3 (TS)’s XtlError / xtlError / isXtlError (ADR-0015) and xl3-py’s XtlError.
eval
Expression parser + evaluator for XTL templates.
functions
Context-free scalar function implementations.
introspect
Surface-area parity with xl3 (TS) / xl3-py introspection APIs.
manifest
Style manifest model exchanged with the JS shell.
output
Output buffer assembly.
output_model
Public output types — mirror the TS / Python sibling APIs so that xl3-wasm and any other host can return the same OutputFile[] shape that convert() produces in xl3 (TS) and xl3-py.
plan
Template plan: the parsed, evaluation-ready representation of a template workbook.
render
Top-level renderer. Glues plan + source + eval + output.
source
Source data reader. Reads the data workbook (data.xlsx) into row records keyed by the header row.
styles
Parse the bits of a template workbook that calamine doesn’t expose: the xl/styles.xml numFmt / cellXfs tables, and each worksheet’s cell-level s="<xf>" attribute. We need this for ADR-0003 numFmt cell coercion ({{ [Amount] }} in a numeric-format cell yields a Number, not the source string).
value
Cell value representation used by the planner, source reader, and evaluator. Deliberately simple — strings, numbers, booleans, plus an explicit Empty so we can distinguish “blank cell” from “empty string”.