ooxml
Rust library for reading and writing Office Open XML formats: DOCX, XLSX, and PPTX.
Crates
| Crate | Description | Docs |
|---|---|---|
ooxml-wml |
WordprocessingML — read/write .docx |
|
ooxml-sml |
SpreadsheetML — read/write .xlsx |
|
ooxml-pml |
PresentationML — read/write .pptx |
|
ooxml-dml |
DrawingML — shared graphics layer | |
ooxml-omml |
Office Math Markup Language | |
ooxml-opc |
OPC packaging core (ZIP, relationships, content types) |
Quick Start
Read a Word document
use Document;
use ;
let doc = open?;
// All paragraphs
for para in doc.body.paragraphs
// Full plain text
println!;
Write a Word document
use ;
let mut builder = new;
// Heading
// Paragraph
builder.add_paragraph;
// Bulleted list
let list_id = builder.add_list;
for item in
// Table
let table = builder.body_mut.add_table;
let row = table.add_row;
for header in
builder.save?;
Read a spreadsheet
use ;
let mut workbook = open?;
println!;
let sheet = workbook.resolved_sheet?;
for row in sheet.rows
Read a presentation
use ;
let mut pres = open?;
for slide in pres.slides?
Features
Each crate uses fine-grained feature flags for smaller compile times. The full feature (enabled by default) includes everything.
ooxml-wml features: wml-styling, wml-tables, wml-layout, wml-hyperlinks, wml-drawings, wml-numbering, wml-comments, wml-fields, wml-track-changes, wml-settings, wml-math, wml-charts
ooxml-sml features: sml-styling, sml-formulas, sml-layout, sml-filtering, sml-validation, sml-comments, sml-charts, sml-hyperlinks, sml-pivot, sml-tables, and more
ooxml-pml features: pml-transitions, pml-animations, pml-notes, pml-comments, pml-styling, pml-masters, pml-hyperlinks, pml-charts
Example minimal dependency:
[]
= { = "0.1", = false, = ["wml-styling"] }
Design
- Typed — every XML element maps to a Rust struct, generated from the ECMA-376 RELAX NG schemas
- Roundtrip-faithful — unknown elements and attributes are preserved, never silently dropped
- Lazy — large parts (worksheets, slide lists) are streamed rather than parsed upfront
- Spec-driven — types and names follow ECMA-376 / ISO 29500; deviations are documented
Status
The library is in active development at v0.1. The core reading and writing APIs for all three formats are functional. See TODO.md for the backlog and SPEC.md for the full roadmap.
License
Licensed under either of MIT or Apache-2.0 at your option.