Skip to content

API-Referenz

Konsolidierte Referenz der Office-Oxide-Oberfläche, nach Konzept geordnet statt nach Binding. Jedes Binding spiegelt dieselbe Form — die Namen folgen den Sprachkonventionen (snake_case in Rust/Python, camelCase in JS, PascalCase in C#/.NET, Pascal in Go).

Document — Read-Handle

Aus einem Pfad öffnen; das Format wird über Erweiterung und Magic-Bytes erkannt.

Konzept Rust Python JavaScript Go C# C
Datei öffnen Document::open(path) Document.open(path) Document.open(path) officeoxide.Open(path) Document.Open(path) office_document_open
Aus Bytes öffnen 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
Reiner 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() (typisiert) .to_ir() (dict) .toIr() (object) .ToIRJSON() .ToIrJson() office_document_to_ir_json
Speichern / konvertieren .save_as(path) .save_as(path) .saveAs(path) .SaveAs(path) .SaveAs(path) office_document_save_as
Schließen drop with-Block verlassen close() / using .Close() Dispose / using office_document_free

DocumentFormat

Docx | Xlsx | Pptx | Doc | Xls | Ppt

Die Format-Strings an FFI-Grenzen (from_bytes etc.) sind die kleingeschriebenen Versionen dieser Namen: "docx", "xlsx", "pptx", "doc", "xls", "ppt".

EditableDocument — Read-modify-write

Gleiche Open-API wie Document. Beim Speichern bleiben alle unveränderten OPC-Teile erhalten.

Konzept Rust Python JavaScript Go C# C
Öffnen EditableDocument::open EditableDocument.open EditableDocument.open OpenEditable EditableDocument.Open office_editable_open
Text ersetzen .replace_text(n, r) .replace_text(n, r) .replaceText(n, r) .ReplaceText(n, r) .ReplaceText(n, r) office_editable_replace_text
XLSX-Zelle setzen .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
Speichern .save(path) .save(path) .save(path) .Save(path) .Save(path) office_editable_save
In Bytes speichern .write_to(w) .save_to_bytes() .saveToBytes() .SaveToBytes() .SaveToBytes() office_editable_save_to_bytes

Editierbare Handles unterstützen nur DOCX, XLSX, PPTX. replace_text-Aufrufe auf XLSX liefern 0; nutze set_cell. set_cell-Aufrufe auf DOCX/PPTX werfen Fehler.

Helfer auf Modulebene

Helfer Liefert Verfügbar in
extract_text(path) UTF-8-String Allen Bindings
to_markdown(path) GFM-Markdown-String Allen Bindings
to_html(path) HTML-Fragment-String Allen Bindings
detect_format(path) Format-Name oder null Allen Bindings
version() "0.1.0" Allen 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 wird Element über das Feld kind dispatcht ("Heading", "Paragraph", "List", "Table", "Image").

Fehler

Fehler exponieren einen typisierten Code plus den Namen der gescheiterten Operation.

Code Bedeutung
0 OK
1 Ungültiges Argument (nil-Pointer, unbekannter Format-String)
2 I/O-Fehler
3 Parsing-Fehler (beschädigtes Dokument)
4 Extraktion fehlgeschlagen (Parsing OK, aber Rendering scheiterte)
5 Interner Fehler (Bug — bitte Issue eröffnen)
6 Nicht unterstützt (Erweiterung oder Feature)
Binding Typ
Rust office_oxide::OfficeError (enum)
Python OfficeOxideError (Exception, .code, .operation)
JavaScript OfficeOxideError (Error-Subklasse, .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 Wirkung
mmap Document::open_mmap für zero-copy OOXML-Öffnen
parallel rayon-basierte Helfer fürs parallele Parsing
serde (Default) Serialize / Deserialize auf den IR-Typen
python PyO3-Bindings (verwendet beim Bauen der office-oxide-Wheel auf PyPI)

Formatspezifische Submodule (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

Nutze die Submodule, wenn du formatspezifischen Zugriff brauchst — Sheet-Iteration, Folien-Manipulation, Custom-XML — über das hinaus, was das einheitliche Document exponiert.

Siehe auch