Skip to content

feat: add support for legacy binary office formats#3804

Open
ceberam wants to merge 3 commits into
mainfrom
feat/old-office-formats
Open

feat: add support for legacy binary office formats#3804
ceberam wants to merge 3 commits into
mainfrom
feat/old-office-formats

Conversation

@ceberam

@ceberam ceberam commented Jul 14, 2026

Copy link
Copy Markdown
Member

Summary

Add support for legacy binary Office formats - .doc (Word 97–2004), .xls (Excel 97–2004), and .ppt (PowerPoint 97–2003) - by converting them to their modern Open XML equivalents via LibreOffice before delegating to the existing
MsWordDocumentBackend, MsExcelDocumentBackend, and MsPowerpointDocumentBackend parsers.

Resolves #1133

Motivation

Docling already supports .docx, .xlsx, and .pptx. Many real-world document collections still contain the older binary formats, which share the same logical structure. LibreOffice is already an optional dependency used elsewhere in Docling (EMF/WMF image rendering, chart rendering), so reusing it here keeps the dependency footprint unchanged.

Changes

New convert_to_modern_format utility

Shared helper that invokes LibreOffice headless to convert a legacy file (accepted as either a Path or a BytesIO stream) to a modern Open XML format and returns a BytesIO buffer.
Cleans up its temporary directory in all cases.

Extended backends

Each of the three existing backends gains support for its legacy counterpart:

Backend New format
MsWordDocumentBackend InputFormat.DOC (.doc, .dot)
MsExcelDocumentBackend InputFormat.XLS (.xls, .xlt)
MsPowerpointDocumentBackend InputFormat.PPT (.ppt, .pot, .pps)

When in_doc.format is a legacy format, __init__ calls convert_to_modern_format before the normal parsing path runs. No new backend classes are introduced.

Format registration

  • InputFormat.DOC, InputFormat.XLS, InputFormat.PPT added to the InputFormat enum.
  • Extension and MIME type mappings added to FormatToExtensions and FormatToMimeType in base_models.py (official MIME types: application/msword, application/vnd.ms-excel, application/vnd.ms-powerpoint).
  • _mime_from_extension in document.py updated to handle the new extensions.
  • _get_default_option in document_converter.py maps each legacy format to the same FormatOption as its modern counterpart.

Correct DocumentOrigin.mimetype

All three backends' convert() methods previously hardcoded the modern MIME type. They now use FormatToMimeType[self.input_format][0], so a .doc file produces mimetype="application/msword" in DocumentOrigin rather than the MIME type of the converted intermediate. All three legacy MIME types are already
accepted by DocumentOrigin's validator via Python's standard mimetypes module — no changes to docling-core are required.

Documentation

  • docs/usage/supported_formats.md — new row for DOC, XLS, PPT in the supported input formats table.
  • pyproject.toml — updated comment on the format-office extras block.

Limitations

  • LibreOffice must be installed and on PATH (or at the standard macOS
    location). Conversion raises RuntimeError when it is not available; the
    end-to-end tests are automatically skipped.

Checklist:

  • Documentation has been updated, if necessary.
  • Examples have been added, if necessary.
  • Tests have been added, if necessary.

ceberam added 2 commits July 14, 2026 18:14
Signed-off-by: Cesar Berrospi Ramis <ceb@zurich.ibm.com>
Signed-off-by: Cesar Berrospi Ramis <ceb@zurich.ibm.com>
@ceberam ceberam added enhancement New feature or request docx issue related to docx backend pptx issue related to pptx backend xlsx issue related to xlsx backend labels Jul 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

DCO Check Passed

Thanks @ceberam, all your commits are properly signed off. 🎉

@mergify

mergify Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Merge Protections

🔴 1 of 2 protections blocking · waiting on 👀 reviews

Protection Waiting on
🔴 Require two reviewer for test updates 👀 reviews
🟢 Enforce conventional commit

🔴 Require two reviewer for test updates

Waiting for

  • #approved-reviews-by >= 2
This rule is failing.

When test data is updated, we require two reviewers

  • #approved-reviews-by >= 2

Show 1 satisfied protection

🟢 Enforce conventional commit

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert)(?:\(.+\))?(!)?:

@ceberam ceberam requested review from cau-git and dolfim-ibm July 14, 2026 16:31
@codecov

codecov Bot commented Jul 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 22.50000% with 31 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
docling/backend/docx/drawingml/utils.py 11.11% 16 Missing ⚠️
docling/datamodel/document.py 0.00% 6 Missing ⚠️
docling/backend/msexcel_backend.py 25.00% 3 Missing ⚠️
docling/backend/mspowerpoint_backend.py 40.00% 3 Missing ⚠️
docling/backend/msword_backend.py 25.00% 3 Missing ⚠️

📢 Thoughts on this report? Let us know!

Signed-off-by: Cesar Berrospi Ramis <ceb@zurich.ibm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docx issue related to docx backend enhancement New feature or request pptx issue related to pptx backend xlsx issue related to xlsx backend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for XLS format

1 participant