Skip to content

レガシー DOC、XLS、PPT を OOXML に変換

Office Oxide は、Word 97–2003(.doc)、Excel 97–2003(.xls)、PowerPoint 97–2003(.ppt)を読み、そして 対応する最新 OOXML を書ける唯一の Rust / Python ライブラリです — JVM(Apache Tika)、外部コンバータ(LibreOffice headless)、商用ライセンス(Aspose)を必要としません。

save_as が 1 回の呼び出しで変換します。レガシーファイルを開き、最新の拡張子で保存すると、Office Oxide が IR を経由して新しい OOXML コンテナを書き出します。

ワンライナー

Rust

use office_oxide::Document;

Document::open("old.doc")?.save_as("modern.docx")?;
Document::open("old.xls")?.save_as("modern.xlsx")?;
Document::open("old.ppt")?.save_as("modern.pptx")?;

Python

from office_oxide import Document

with Document.open("old.doc") as doc:
    doc.save_as("modern.docx")

with Document.open("old.xls") as doc:
    doc.save_as("modern.xlsx")

with Document.open("old.ppt") as doc:
    doc.save_as("modern.pptx")

JavaScript

import { Document } from 'office-oxide';

using doc = Document.open('old.xls');
doc.saveAs('modern.xlsx');

Go

doc, _ := officeoxide.Open("old.xls")
defer doc.Close()
doc.SaveAs("modern.xlsx")

C#

using var doc = Document.Open("old.xls");
doc.SaveAs("modern.xlsx");

一括移行

コーパスをワンライナーで移行。

Python

from pathlib import Path
from office_oxide import Document

for src in Path("legacy").rglob("*"):
    if src.suffix.lower() in {".doc", ".xls", ".ppt"}:
        new_ext = {".doc": ".docx", ".xls": ".xlsx", ".ppt": ".pptx"}[src.suffix.lower()]
        dst = Path("modern") / src.relative_to("legacy").with_suffix(new_ext)
        dst.parent.mkdir(parents=True, exist_ok=True)
        with Document.open(src) as doc:
            doc.save_as(dst)
        print(f"{src}{dst}")

Rust

use office_oxide::Document;
use std::path::Path;

fn migrate(src: &Path, dst: &Path) -> office_oxide::Result<()> {
    Document::open(src)?.save_as(dst)?;
    Ok(())
}

大規模コーパスの並列移行のために rayon でループをラップしてください。

シェル — CLI を使用

find legacy/ -iname '*.doc' | parallel \
  'office-oxide convert {} modern/{/.}.docx'

find legacy/ -iname '*.xls' | parallel \
  'office-oxide convert {} modern/{/.}.xlsx'

find legacy/ -iname '*.ppt' | parallel \
  'office-oxide convert {} modern/{/.}.pptx'

ラウンドトリップで何が残るか

Office Oxide は コンテンツの形 — 段落、テーブル、セル、スライド、リスト、見出し — とその中の値を保持します。レガシーフォーマットがプロプライエタリな構造で IR がモデル化していないものはいくつか移行されません:

カテゴリ 移行
段落テキスト 太字/斜体/下線の run を含む
リスト 順序付き + 順序なし
テーブル セル、行順、ヘッダ行
XLSX セル値(文字列、数値、ブール)
シート名
スライドタイトル + 本文
ハイパーリンク
画像 partial DOC/PPT はインライン画像保存; XLS の画像アンカーは削除
コメント / リビジョン 変更履歴はフラット化
数式(XLS) 値のみ キャッシュされた数式結果は残るが、数式式はラウンドトリップしない
WordArt、SmartArt、グラフ 必要ならターゲットフォーマットで再レンダー
暗号化 レガシーファイルを先に復号(例: LibreOffice 経由)

LLM、インデックス化、アーカイブ用途のほとんどでは、コンテンツレベルの忠実度が重要 — そして Office Oxide は数ミリ秒でフルに編集可能な DOCX/XLSX/PPTX を返します。

パフォーマンス

ファイル単位の変換はテキスト抽出と同じオーダーで動作。典型的な Word 97 .docシングル桁ミリ秒 をエンドツーエンドで期待してください。

関連項目