1. Products
  2.   Spreadsheet
  3.   Rust
  4.   umya-spreadsheet

umya-spreadsheet

 
 

Pure Rust Library for XLSX/XLSM Files

Read, Write, Style, and Manipulate XLSX/XLSM Spreadsheets with Zero External Dependencies.

What is umya-spreadsheet?

umya-spreadsheet is a high-performance, pure Rust library for reading and writing Excel spreadsheet files in XLSX and XLSM formats. Designed for safety and efficiency, it avoids unsafe code and external dependencies, making it ideal for desktop applications, server-side processing, and WebAssembly environments. The library provides a clean, idiomatic Rust API for accessing cells, rows, columns, styles, charts, and images, enabling developers to build robust spreadsheet tools without relying on Microsoft Office or COM interop.

With full support for lazy loading, password protection, and rich formatting, umya-spreadsheet bridges the gap between performance and usability. It supports CSV export, chart generation, image embedding, and range operations like moving and copying. The project is actively maintained, well-documented, and tested, with a focus on correctness and compatibility with modern Excel features. Developers can integrate it into CLI tools, web backends, or desktop apps using frameworks like Tauri or Axo.

Previous Next

Getting Started with umya-spreadsheet

To begin using umya-spreadsheet, add it to your Cargo.toml with `umya-spreadsheet = "3.1.1"`. For WebAssembly support, enable the `js` feature. The library is dependency-light and compiles quickly. Once installed, import it via `extern crate umya_spreadsheet;` and start reading or writing spreadsheets. You can also explore the umya-spreadsheet GitHub for examples, tests, and documentation. It supports lazy loading for large files and offers robust error handling.

Install umya-spreadsheet via Cargo

[dependencies]
umya-spreadsheet = "3.1.1"

# WebAssembly support
umya-spreadsheet = { version = "3.1.1", features = ["js"] }

Read & Write XLSX/XLSM Files

umya-spreadsheet provides intuitive APIs for reading and writing XLSX and XLMS files. Use `reader::xlsx::read()` to load a workbook from disk, or `new_file()` to create a blank one. Writing is equally simple: call `writer::xlsx::write()` with the workbook and target path. The library supports lazy loading via `lazy_read()` for improved performance on large files, and allows password-protected writing or setting passwords post-creation. All operations are safe, zero-copy where possible, and avoid external binaries.

How to Read and Write an XLSX File via Rust?

use std::path::Path;

// Read file
let path = Path::new("./input.xlsx");
let mut book = umya_spreadsheet::reader::xlsx::read(path).unwrap();

// Write file
let out_path = Path::new("./output.xlsx");
umya_spreadsheet::writer::xlsx::write(&book, out_path).unwrap();

Cell Access & Style Manipulation

Accessing and modifying cell values is straightforward: use `cell("A1")` or `cell((1,1))` for reading, and `cell_mut()` for writing. Styles are managed via `style_mut()`, allowing background color, font, borders, and alignment changes. The library exposes a rich set of style properties while maintaining immutability guarantees where possible. You can also retrieve formatted values, apply conditional logic, and batch update styles across ranges. This makes it ideal for generating reports, dashboards, or data exports with consistent formatting.

How to Modify Cell Value and Style via Rust?

let mut book = umya_spreadsheet::new_file();
book.sheet_by_name_mut("Sheet1")
    .unwrap()
    .cell_mut("A1")
    .set_value("Hello, Rust!");

let mut style = book.sheet_by_name_mut("Sheet1")
    .unwrap()
    .style_mut("A1");
style.set_background_color(umya_spreadsheet::Color::COLOR_RED);

Charts & Image Support

umya-spreadsheet supports creating and editing charts—including line, bar, and area charts—by defining series ranges and markers. You can embed images directly into sheets using the `Image` struct, with support for PNG and other formats depending on features enabled. Charts and images integrate seamlessly with cell coordinates and drawing layers, enabling dynamic dashboard generation. While some advanced drawing features are still evolving, the core functionality is production-ready and extensible.

How to Add a Line Chart to a Spreadsheet via Rust?

let mut book = umya_spreadsheet::new_file();
let mut from_marker = umya_spreadsheet::structs::drawing::spreadsheet::MarkerType::default();
from_marker.set_coordinate("C1");
let mut to_marker = umya_spreadsheet::structs::drawing::spreadsheet::MarkerType::default();
to_marker.set_coordinate("D11");
let series = vec!["Sheet1!$A$1:$A$10", "Sheet1!$B$1:$B$10"];
let mut chart = umya_spreadsheet::structs::Chart::default();
chart.new_chart(
    umya_spreadsheet::structs::ChartType::LineChart,
    from_marker,
    to_marker,
    series,
);
book.sheet_by_name_mut("Sheet1")
    .unwrap()
    .add_chart(chart);

Range Operations & Password Protection

Perform advanced operations like moving, copying, and resizing ranges using `move_range()`, enabling dynamic data reorganization. The library also supports password-protected workbooks: write files with `write_with_password()` or apply passwords to existing files via `set_password()`. These features are critical for secure data handling in enterprise or compliance-sensitive applications. Combined with zero-dependency design and WASM compatibility, umya-spreadsheet delivers both flexibility and security.

How to Move a Range and Protect a File with Password via Rust?

// Move range
let range = "A1:A3";
book.sheet_by_name_mut("Sheet1")
    .unwrap()
    .move_range(range, &10, &2);

// Password protection
umya_spreadsheet::writer::xlsx::write_with_password(
    &book,
    Path::new("./protected.xlsx"),
    "mypassword",
).unwrap();