Skip to content

API 레퍼런스

바인딩별이 아니라 개념별로 정리된 Office Oxide 표면 통합 레퍼런스. 각 바인딩은 같은 형태를 그대로 따릅니다 — 이름은 언어 관습을 따릅니다(Rust/Python은 snake_case, JS는 camelCase, C#/.NET은 PascalCase, Go는 Pascal).

Document — 읽기 핸들

경로에서 열기; 형식은 확장자와 매직 바이트로 감지됩니다.

개념 Rust Python JavaScript Go C# C
파일 열기 Document::open(path) Document.open(path) Document.open(path) officeoxide.Open(path) Document.Open(path) office_document_open
바이트에서 열기 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 office_document_format
일반 텍스트 .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() (타입 있음) .to_ir() (dict) .toIr() (object) .ToIRJSON() .ToIrJson() office_document_to_ir_json
저장 / 변환 .save_as(path) .save_as(path) .saveAs(path) .SaveAs(path) .SaveAs(path) office_document_save_as
닫기 drop with 블록 종료 close() / using .Close() Dispose / using office_document_free

DocumentFormat

Docx | Xlsx | Pptx | Doc | Xls | Ppt

FFI 경계(from_bytes 등)에서 쓰는 형식 문자열은 소문자 버전입니다: "docx", "xlsx", "pptx", "doc", "xls", "ppt".

EditableDocument — read-modify-write

Document와 같은 열기 API. 저장은 변경되지 않은 모든 OPC 파트를 보존합니다.

개념 Rust Python JavaScript Go C# C
열기 EditableDocument::open EditableDocument.open EditableDocument.open OpenEditable EditableDocument.Open office_editable_open
텍스트 치환 .replace_text(n, r) .replace_text(n, r) .replaceText(n, r) .ReplaceText(n, r) .ReplaceText(n, r) office_editable_replace_text
XLSX 셀 설정 .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(path) .save(path) .save(path) .Save(path) .Save(path) office_editable_save
바이트로 저장 .write_to(w) .save_to_bytes() .saveToBytes() .SaveToBytes() .SaveToBytes() office_editable_save_to_bytes

편집 가능한 핸들은 DOCX, XLSX, PPTX만 지원합니다. XLSX에서 replace_text 호출은 0을 반환합니다 — set_cell을 사용하세요. DOCX/PPTX에서 set_cell 호출은 오류를 냅니다.

모듈 레벨 헬퍼

헬퍼 반환 사용 가능
extract_text(path) UTF-8 문자열 모든 바인딩
to_markdown(path) GFM Markdown 문자열 모든 바인딩
to_html(path) HTML fragment 문자열 모든 바인딩
detect_format(path) 형식 이름 또는 null 모든 바인딩
version() "0.1.0" 모든 바인딩
create_from_ir(ir, fmt, path) unit / void Rust, Python

DocumentIR — 스키마

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>
}

Python에서는 Elementkind 필드("Heading", "Paragraph", "List", "Table", "Image")로 디스패치됩니다.

오류

오류는 타입화된 코드와 실패한 작업 이름을 노출합니다.

Code 의미
0 OK
1 잘못된 인자(nil 포인터, 알 수 없는 형식 문자열)
2 I/O 오류
3 파싱 오류(손상된 문서)
4 추출 실패(파싱은 성공했지만 렌더링 실패)
5 내부 오류(버그 — 이슈 등록)
6 미지원(확장자 또는 기능)
바인딩 타입
Rust office_oxide::OfficeError(enum)
Python OfficeOxideError(예외, .code, .operation)
JavaScript OfficeOxideError(Error 서브클래스, .code, .operation)
Go *officeoxide.Error(.Code, .Op)
C# OfficeOxideException(.Code, .Operation)
C int *error_code 출력 매개변수

Feature 플래그(Rust 크레이트)

[dependencies]
office_oxide = { version = "0.1.0", features = ["mmap", "parallel"] }
Feature 효과
mmap 제로카피 OOXML 열기를 위한 Document::open_mmap
parallel rayon 기반 병렬 파싱 헬퍼
serde (기본) IR 타입에 Serialize / Deserialize
python PyO3 바인딩(office-oxide PyPI wheel 빌드에서 사용)

형식별 서브모듈(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

통합 Document가 노출하는 범위를 넘어서는 형식별 접근 — 시트 순회, 슬라이드 조작, 커스텀 XML — 이 필요할 때 서브모듈을 사용하세요.

더 보기