Skip to content

ValueError: 'WD_PARAGRAPH_ALIGNMENT.CENTER' is not a valid WD_PARAGRAPH_ALIGNMENT #1508

@americanexplorer13

Description

@americanexplorer13

I'm just trying to add alignment for title in new docx, but this error appears. Why is this happens?

title.alignment = WD_ALIGN_PARAGRAPH.CENTER
Traceback (most recent call last):
  File "<DELETED_PATH>/local_run.py", line 41, in <module>
    result = reporter.generate_report(docx_path, result)
  File "<DELETED_PATH>/src/core/report.py", line 35, in generate_report
    title.alignment = self.report_settings.paragraph["alignment"]
  File "<DELETED_PATH>/venv/lib/python3.10/site-packages/docx/text/paragraph.py", line 59, in alignment
    self._p.alignment = value
  File "<DELETED_PATH>/venv/lib/python3.10/site-packages/docx/oxml/text/paragraph.py", line 50, in alignment
    pPr.jc_val = value
  File "<DELETED_PATH>/venv/lib/python3.10/site-packages/docx/oxml/text/parfmt.py", line 193, in jc_val
    self.get_or_add_jc().val = value
  File "<DELETED_PATH>/venv/lib/python3.10/site-packages/docx/oxml/xmlchemy.py", line 256, in set_attr_value
    str_value = self._simple_type.to_xml(value)
  File <DELETED_PATH>/venv/lib/python3.10/site-packages/docx/enum/base.py", line 73, in to_xml
    member = cls(value)
  File "/usr/lib/python3.10/enum.py", line 385, in __call__
    return cls.__new__(cls, value)
  File "/usr/lib/python3.10/enum.py", line 710, in __new__
    raise ve_exc
ValueError: 'WD_PARAGRAPH_ALIGNMENT.CENTER' is not a valid WD_PARAGRAPH_ALIGNMENT

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions