-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Open
Description
Summary
I've been having issues with adding bullet points to my .docx file (and, unlike in #204+), it is one.
I received a file using a company-made theme that does not contain any style for bullet points (among other oddities), and the was almost empty. Attempting to add bullet points programmatically (using code found on stack overflow) lead to the error below.
Adding bullet points to the file and then removing them seems to do the trick.
My question is: is there a way to add the probably missing metadata (I don't know what it is, I'm no expert in MSOffice formats) back into the file, so that my users don't have to do this ?
L;DR
Minimum viable example
import docx
doc = docx.Document('/path/to/file.docx')
doc.part.numbering_part # error belowStack trace
Traceback (most recent call last):
File ".\venv\docx\parts\document.py", line 105, in numbering_part
return cast(NumberingPart, self.part_related_by(RT.NUMBERING))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".\venv\docx\opc\part.py", line 124, in part_related_by
return self.rels.part_with_reltype(reltype)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".\venv\docx\opc\rel.py", line 52, in part_with_reltype
rel = self._get_rel_of_type(reltype)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".\venv\docx\opc\rel.py", line 98, in _get_rel_of_type
raise KeyError(tmpl % reltype)
KeyError: "no relationship of type 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering' in collection"
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File ".\code.py", line 3, in <module>
value = self._fget(obj)
^^^^^^^^^^^^^^^
File ".\venv\docx\parts\document.py", line 107, in numbering_part
numbering_part = NumberingPart.new()
^^^^^^^^^^^^^^^^^^^
File ".\venv\docx\parts\numbering.py", line 14, in new
raise NotImplementedError
NotImplementedError
- Version:
1.2.0 - Python:
3.12.12 - OS: Windows 11
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels