Skip to content

API Reference

A consolidated reference of Office Oxide’s surface area, organized by concept rather than by binding. Each binding mirrors the same shape — names follow language conventions (snake_case in Rust/Python, camelCase in JS, PascalCase in C#/.NET, Pascal in Go).

Document — read handle

Open from a path; format detected from extension and magic bytes.

Concept Rust Python JavaScript Go C# C
Open file Document::open(path) Document.open(path) Document.open(path) officeoxide.Open(path) Document.Open(path) office_document_open
Open bytes Document::from_reader(r, fmt) Document.from_bytes(b, fmt) Document.fromBytes(b, fmt) OpenFromBytes(b, fmt) Document.FromBytes(b, fmt) office_document_open_from_bytes
Format .format() .format .format .Format() .Format office_document_format
Plain text .plain_text() .plain_text() .plainText() .PlainText() .PlainText() office_document_plain_text
Markdown .to_markdown() .to_markdown() .toMarkdown() .ToMarkdown() .ToMarkdown() office_document_to_markdown
HTML .to_html() .to_html() .toHtml() .ToHTML() .ToHtml() office_document_to_html
IR .to_ir() (typed) .to_ir() (dict) .toIr() (object) .ToIRJSON() .ToIrJson() office_document_to_ir_json
Save / convert .save_as(path) .save_as(path) .saveAs(path) .SaveAs(path) .SaveAs(path) office_document_save_as
Close drop with-block exit close() / using .Close() Dispose / using office_document_free

DocumentFormat

Docx | Xlsx | Pptx | Doc | Xls | Ppt

The format strings used at FFI boundaries (from_bytes etc.) are lowercase versions of these names: "docx", "xlsx", "pptx", "doc", "xls", "ppt".

EditableDocument — read-modify-write

Same opening API as Document. Save preserves all unmodified OPC parts.

Concept Rust Python JavaScript Go C# C
Open EditableDocument::open EditableDocument.open EditableDocument.open OpenEditable EditableDocument.Open office_editable_open
Replace text .replace_text(n, r) .replace_text(n, r) .replaceText(n, r) .ReplaceText(n, r) .ReplaceText(n, r) office_editable_replace_text
Set XLSX cell .set_cell(idx, ref, v) .set_cell(idx, ref, v) .setCell(idx, ref, v) .SetCell(idx, ref, v) .SetCell(idx, ref, v) office_editable_set_cell
Save .save(path) .save(path) .save(path) .Save(path) .Save(path) office_editable_save
Save bytes .write_to(w) .save_to_bytes() .saveToBytes() .SaveToBytes() .SaveToBytes() office_editable_save_to_bytes

Editable handles support DOCX, XLSX, PPTX only. Calling replace_text on XLSX returns 0; use set_cell. Calling set_cell on DOCX/PPTX errors.

Module-level helpers

Helper Returns Available in
extract_text(path) UTF-8 string All bindings
to_markdown(path) GFM Markdown string All bindings
to_html(path) HTML fragment string All bindings
detect_format(path) format name or null All bindings
version() "0.1.0" All bindings
create_from_ir(ir, fmt, path) unit / void Rust, Python

DocumentIR — schema

DocumentIR {
    sections: [Section]
}

Section {
    title:    Option<string>
    elements: [Element]
}

Element = Heading   { level, text }
        | Paragraph { runs: [Run] }
        | List      { ordered, items: [string] }
        | Table     { rows: [[string]] }
        | Image     { filename, data: bytes }

Run {
    text, bold, italic, underline, hyperlink: Option<string>
}

In Python, Element is dispatched by the kind field ("Heading", "Paragraph", "List", "Table", "Image").

Errors

Errors expose a typed code plus the failing operation name.

Code Meaning
0 OK
1 Invalid argument (nil pointer, unknown format string)
2 I/O error
3 Parse error (malformed document)
4 Extraction failed (parsed but render failed)
5 Internal error (bug — please file an issue)
6 Unsupported (extension or feature)
Binding Type
Rust office_oxide::OfficeError (enum)
Python OfficeOxideError (exception, .code, .operation)
JavaScript OfficeOxideError (Error subclass, .code, .operation)
Go *officeoxide.Error (.Code, .Op)
C# OfficeOxideException (.Code, .Operation)
C int *error_code out-parameter

Feature flags (Rust crate)

[dependencies]
office_oxide = { version = "0.1.0", features = ["mmap", "parallel"] }
Feature Effect
mmap Document::open_mmap for zero-copy OOXML opens
parallel rayon-based parallel parse helpers
serde (default) Serialize / Deserialize on IR types
python PyO3 bindings (used by the office-oxide PyPI wheel build)

Per-format sub-modules (Rust)

office_oxide::docx   — DocxDocument, DocxBuilder, edit::DocxEditor
office_oxide::xlsx   — XlsxDocument, XlsxBuilder, edit::{XlsxEditor, CellValue}
office_oxide::pptx   — PptxDocument, PptxBuilder, edit::PptxEditor
office_oxide::doc    — DocDocument
office_oxide::xls    — XlsDocument
office_oxide::ppt    — PptDocument
office_oxide::ir     — DocumentIR, Section, Element, Run
office_oxide::edit   — EditableDocument
office_oxide::create — create_from_ir

Use the sub-modules when you need format-specific access — sheet iteration, slide manipulation, custom XML — beyond what the unified Document exposes.

See also