Skip to content
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

WD_PARAGRAPH_ALIGNMENT EXTENTION #1473

Open
yanedev opened this issue Feb 26, 2025 · 2 comments
Open

WD_PARAGRAPH_ALIGNMENT EXTENTION #1473

yanedev opened this issue Feb 26, 2025 · 2 comments

Comments

@yanedev
Copy link

yanedev commented Feb 26, 2025

ValueError: WD_PARAGRAPH_ALIGNMENT has no XML mapping for 'start'

Is it possible to add on existing (left, center, right) the start and end mappings so that this error is avoided. If I'm correct it should be added in the

class WD_PARAGRAPH_ALIGNMENT(BaseXmlEnum):
    LEFT = (0, "left", "Left-aligned")
    """Left-aligned"""

    CENTER = (1, "center", "Center-aligned.")
    """Center-aligned."""

    RIGHT = (2, "right", "Right-aligned.")
    """Right-aligned."""
...

like

END = (0, "left", "Left-aligned")

or

LEFT = (0, "left", "Left-aligned", "start")

@yanedev
Copy link
Author

yanedev commented Feb 26, 2025

probably not that easy but worth a try

@yanedev
Copy link
Author

yanedev commented Feb 26, 2025

I've managed to avoid it with the code bellow, if anyone else has similar problems. It's not the best but it works in my case

try:
    new_cell.paragraphs[0].alignment = cell.paragraphs[0].alignment
except Exception as e:
    error_msg = str(e)
    if "start" in error_msg:
        new_cell.paragraphs[0].alignment = WD_PARAGRAPH_ALIGNMENT.LEFT
    elif "end" in error_msg:
        new_cell.paragraphs[0].alignment = WD_PARAGRAPH_ALIGNMENT.RIGHT
    else:
        print(error_msg)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant