Skip to main content

Crate visi_core

Crate visi_core 

Source
Expand description

visi-core: an embeddable spreadsheet engine.

Excel formula compilation and evaluation, dependency-tracked recalculation, and .xlsx import/export. Makes no CLI or filesystem assumptions – everything is driven through byte buffers – and uses web-time and getrandom rather than std::time so it can target wasm.

§Getting started

WorkbookManager is the entry point. It owns a workbook’s sheets, charts, pivot tables and VBA project, and is the layer that makes cross-sheet formulas and pivot tables behave correctly – see its documentation before reaching for core::engine::Sheet directly.

use visi_core::WorkbookManager;

let bytes = std::fs::read("book.xlsx")?;
let mut wb = WorkbookManager::load_bytes(&bytes)?;

// 0-based (row, col); A1 notation is a boundary concern.
wb.set_cell(0, 0, 0, "=SUM(Sheet2!A1:A10)".to_string());
wb.evaluate()?;

std::fs::write("out.xlsx", wb.save_bytes()?)?;

§Errors

Fallible calls return Error, which implements std::error::Error and so composes with anyhow, eyre, or Box<dyn Error>. Failures that name a workbook object carry an ObjectKind rather than only a message, so callers can react without parsing text:

use visi_core::{Error, ObjectKind, WorkbookManager};

match wb.rename_sheet("Sheet1", "Data") {
    Err(Error::NotFound { kind: ObjectKind::Sheet, name, .. }) => {
        eprintln!("no sheet called {name}");
    }
    other => other?,
}

§Stability

Pre-1.0; the public API is still moving. Modules that exist to implement Excel’s function library are crate-private – what is re-exported here and from core is the intended surface.

Re-exports§

pub use core::workbook::SheetSummary;
pub use core::workbook::WorkbookManager;
pub use core::workbook::WorkbookSummary;
pub use core::xlsx::export_xlsx_data;
pub use core::xlsx::import_xlsx_data;

Modules§

core
The engine’s modules: sheets and cells, Excel Tables, pivot tables, charts, styling, VBA, and .xlsx I/O.

Enums§

Error
Errors returned by visi-core’s public API.
ObjectKind
The kind of workbook object an Error refers to.

Type Aliases§

Result
A Result whose error type is Error.