openprxl 0.1.0

A Rust spreadsheet library inspired by Python's openpyxl
Documentation

openprxl

A Rust spreadsheet library inspired by Python's openpyxl. It can read and write .xlsx (Office Open XML) workbooks with an ergonomic, familiar API.

Features

  • Create, save, and load .xlsx files
  • Multiple worksheets
  • Cell values: strings, numbers, booleans, dates, formulas, errors
  • Cell styles: font, fill, border, alignment, number format
  • Row heights / column widths
  • Merged cells
  • Shared string table for compact storage
  • Round-trip preservation of values, formulas, styles, and merges

Quick start

use openprxl::{Workbook, Style, Font, PatternFill, Alignment, HorizontalAlignment};

fn main() -> openprxl::Result<()> {
    let mut wb = Workbook::new();
    let style_id = wb.register_style(
        Style::default()
            .font(Font::default().bold(true).size(14.0))
            .fill(PatternFill::solid("FFFF00"))
            .alignment(Alignment::default().horizontal(HorizontalAlignment::Center)),
    );

    let ws = wb.active_sheet_mut();
    ws["A1"] = "Hello".into();
    ws["B1"] = 42.0.into();
    ws.cell_mut("C1")?.set_formula("=A1&B1");
    ws.set_cell_style("A1", style_id)?;
    ws.set_column_width("A", 20.0)?;
    ws.set_row_height(1, 30.0);
    ws.merge_cells("A1:B1")?;

    wb.save("example.xlsx")?;
    Ok(())
}

Loading an existing workbook

use openprxl::Workbook;

fn main() -> openprxl::Result<()> {
    let wb = Workbook::load("existing.xlsx")?;
    let ws = wb.active_sheet();
    if let Some(value) = ws["A1"].value().as_string() {
        println!("A1 = {}", value);
    }
    Ok(())
}

Scope

openprxl targets the core 80 % use-case: creating and editing spreadsheets with values, formulas, styles, and layout. Advanced features such as charts, images, pivot tables, conditional formatting, and VBA are not yet supported.

License

Licensed under either of the Apache License, Version 2.0 or the MIT license at your option.