Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Feature: Add support for .dotx Word templates (#1532) #1537

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
coderamaster wants to merge 1 commit into python-openxml:master
base: master
Choose a base branch
Loading
from coderamaster:fix/1532-dotx-template-support

Conversation

@coderamaster
Copy link

@coderamaster coderamaster commented Jan 21, 2026

Description

Fixes #1532.

Adds support for loading Word template files (.dotx) with python-docx.Document().


Problem

Loading a .dotx file currently raises a ValueError due to an unsupported content type. Even if bypassed, the part factory creates a generic Part instead of DocumentPart, causing an AttributeError.


Solution

Treat .dotx templates the same as .docx documents, which matches the OOXML spec.

Changes:

  • Accept Word template main content type
  • Map template content type to DocumentPart
  • Add tests for .dotx loading

Testing

  • Added tests for .dotx files
  • Verified with a real template created in Microsoft Word
  • Confirmed .docx behavior remains unchanged

- Added WML_TEMPLATE_MAIN content type constant
- Updated Document() to accept both .docx and .dotx files
- Added part factory mapping for template content type
- Added tests for .dotx template loading
- Fixes python-openxml#1532 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

ValueError when loading .dotx Word template – lack of native template support

1 participant

AltStyle によって変換されたページ (->オリジナル) /