Aspose.Cells FOSS for Rust is an open-source library for working with Excel XLSX spreadsheets in Rust applications. It gives systems programmers a native, memory-safe way to create workbooks from scratch, load existing XLSX files, modify their contents, and save the result — without Microsoft Office, COM automation, or any external runtime.
The crate models the full spreadsheet object tree: Workbook, Worksheet,
and cell collections with typed value setters (put_value_string,
put_value_i32, put_value_bool, put_value_decimal), formulas with
cached values via put_formula_with_cached_value, charts (Chart,
ChartType), conditional formatting (FormatCondition), data validation
(Validation), auto-filters (AutoFilter), cell styling (CellStyle,
Font, Fill, Borders), page setup (PageSetup), pictures, shapes,
comments, hyperlinks, tables (ListObject), sparklines
(SparklineGroup), defined names, and workbook/worksheet protection.
Aspose.Cells FOSS for Rust is MIT licensed and targets Rust edition 2021.
It installs as a standard Cargo dependency from the GitHub repository —
see the installation guide for the exact Cargo.toml entry. Errors are
surfaced through conventional Result types (CellsError), and XLSX
loading offers repair options (LoadOptions) with structured diagnostics
(LoadDiagnostics). For the enterprise product family, see Aspose.Cells — Enterprise Product Family.
Workbook::new or load existing files with Workbook::load_xlsxadd_worksheet, worksheet, and mutable worksheet collectionssave, save_xlsx, or format-explicit save_with_formatput_value_string, put_value_i32, put_value_bool, put_value_decimal, put_value_date_timeput_formula_with_cached_valuedisplay_string_value and value_typeget, get_by_index)CellStyle with Font, Fill, and BordersStyleFlagNumberFormatPageSetup (paper size, orientation, margins)FreezePane; control row/column visibilityChartType on a sheet’s chart collectionChart, ChartCollection)Picture and drawing shapes with ShapeSparklineGroupFormatConditionValidation with OperatorTypeAutoFilter; structured tables via ListObjectDefinedName; protection via WorkbookProtection and WorksheetProtectionLoadOptions repair flags and LoadDiagnosticsCreate a workbook, write typed values and a formula with a cached result, save it as XLSX, and load it back:
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("C1")?.put_value_bool(true)?;
cells.get("D1")?.put_value_decimal(12.5)?;
cells.get("F1")?.put_value_i32(10)?;
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(())
}
Open workbooks defensively with LoadOptions repair flags and inspect structured load diagnostics:
let options = LoadOptions {
try_repair_package: true,
try_repair_xml: true,
..LoadOptions::default()
};
let loaded = Workbook::load_xlsx_with_options(&valid_path, &options)?;
let sheet = loaded.worksheet("Sheet1")?;
let cells = sheet.get_cells();
println!("Saved: {}", valid_path.display());
println!(
"Loaded workbook with {} worksheet(s) and {} diagnostic issue(s).",
loaded.get_worksheets().count(),
loaded.get_load_diagnostics().issues().len()
);
Fill a data range, then anchor column and line charts to it:
let mut charts = sheet.get_charts();
charts.add(
ChartType::Column,
"Charts!$B$1:$B$13".to_string(),
0,
4,
18,
8,
)?;
charts.add(
ChartType::Line,
"Charts!$C$1:$C$13".to_string(),
0,
9,
18,
13,
)?;
The crate is released under the MIT License; the full text ships in the repository as LICENSE.txt.
Yes. The MIT License permits commercial use, modification, and redistribution, provided the copyright and license notice is preserved.
Add aspose-cells-foss-rust to your Cargo.toml as a git dependency from the GitHub repository — the crate is not yet published on crates.io.
XLSX, with full round-trip read and write via Workbook::load_xlsx and save. Other spreadsheet formats are not supported in the current release.
No. The library reads and writes the XLSX package format directly — no Office installation, COM automation, or external runtime is involved.