Introduction
Aspose.Cells FOSS for Rust brings the Aspose.Cells FOSS family to the Rust
ecosystem. The aspose-cells-foss-rust crate lets Rust applications create
Excel XLSX workbooks from scratch, load existing files, modify their contents,
and save the result — with no Microsoft Office installation, COM automation,
or external runtime involved.
The crate is MIT licensed and targets Rust edition 2021. It follows the
conventions Rust developers expect: constructors like Workbook::new,
Result-based error handling through CellsError, and explicit mutable
accessors such as get_worksheets_mut and get_cells_mut that keep borrow
rules clear. If you build backend services, CLI tools, or data pipelines that
need to produce or consume spreadsheets, this library gives you a native way
to do it.
Aspose.Cells FOSS is already available for .NET, C++, Java, Python, and TypeScript; the Rust crate joins the family with the same focus: honest, verifiable XLSX support under a permissive license.
What’s Included
Workbooks, Worksheets, and Typed Cell Values
A Workbook starts with one worksheet and grows via add_worksheet. Cells
accept typed values — strings, integers, booleans, decimals, and date-times —
through dedicated setters, so no stringly-typed conversions are needed:
let mut workbook = Workbook::new();
{
let mut worksheets = workbook.get_worksheets_mut();
let sheet = worksheets.get(0)?;
let mut cells = sheet.get_cells_mut();
cells.get("A1")?.put_value_string("Hello")?;
cells.get("B1")?.put_value_i32(123)?;
cells.get("C1")?.put_value_bool(true)?;
cells.get("D1")?.put_value_decimal(12.5)?;
}
workbook.save("hello.xlsx")?;
Formulas with Cached Results
Formulas are written together with a cached value, so the saved file opens in Excel with correct results immediately — no recalculation pass required:
cells.get("F1")?.put_value_i32(10)?;
cells.get("G1")?
.put_formula_with_cached_value("=F1*2", CellValue::Number(20.0))?;
Charts Anchored to Data Ranges
Column, line, and other chart types from the ChartType enum can be anchored
to cell ranges on a worksheet, and chart geometry can be read back from loaded
files:
let mut charts = sheet.get_charts();
charts.add(
ChartType::Column,
"Charts!$B$1:$B$13".to_string(),
0,
4,
18,
8,
)?;
Styling, Page Setup, and Structure
Cell formatting flows through CellStyle with Font, Fill, and Borders,
applied selectively with StyleFlag. PageSetup controls paper size and
orientation for print, FreezePane keeps header rows visible, and structured
tables come via ListObject with TableStyleType.
Validation, Conditional Formatting, and Filters
Data-quality features are part of the core surface: Validation rules with
OperatorType, conditional formatting through FormatCondition, auto-filters
via AutoFilter, defined names via DefinedName, and workbook or worksheet
protection through WorkbookProtection and WorksheetProtection.
Defensive Loading with Diagnostics
Real-world XLSX files are not always well-formed. LoadOptions exposes repair
flags, and LoadDiagnostics reports what the loader encountered:
let options = LoadOptions {
try_repair_package: true,
try_repair_xml: true,
..LoadOptions::default()
};
let loaded = Workbook::load_xlsx_with_options(&valid_path, &options)?;
println!(
"Loaded workbook with {} worksheet(s) and {} diagnostic issue(s).",
loaded.get_worksheets().count(),
loaded.get_load_diagnostics().issues().len()
);
Quick Start
Add the crate to your Cargo.toml as a git dependency (the crate is not yet
published on crates.io):
# Cargo.toml
[dependencies]
aspose-cells-foss-rust = { git = "https://github.com/aspose-cells-foss/Aspose.Cells-FOSS-for-Rust" }Then create, save, and reload your first workbook:
use aspose_cells_foss_rust::{CellValue, Workbook};
use std::error::Error;
fn main() -> Result<(), Box<dyn Error>> {
// Create a new workbook (starts with one sheet, "Sheet1").
let mut workbook = Workbook::new();
{
let mut worksheets = workbook.get_worksheets_mut();
let sheet = worksheets.get(0)?;
let mut cells = sheet.get_cells_mut();
cells.get("A1")?.put_value_string("Hello")?;
cells.get("B1")?.put_value_i32(123)?;
cells.get("G1")?
.put_formula_with_cached_value("=F1*2", CellValue::Number(20.0))?;
}
workbook.save("hello.xlsx")?;
// Load it back.
let loaded = Workbook::load_xlsx("hello.xlsx")?;
let sheet = loaded.worksheet("Sheet1")?;
let cells = sheet.get_cells();
println!("A1 = {}", cells.get("A1")?.display_string_value());
Ok(())
}
Supported Formats
| Format | Extension | Read | Write |
|---|---|---|---|
| XLSX | .xlsx | ✓ | ✓ |
XLSX is the focus of the current release: full round-trip read and write via
Workbook::load_xlsx and Workbook::save, with LoadFormat and SaveFormat
enums governing explicit format selection.
Open Source & Licensing
Aspose.Cells FOSS for Rust is MIT licensed. The complete source code is available on GitHub, and the license permits commercial use, modification, and redistribution.