python-openxml / python-docx

Create and modify Word documents with Python
MIT License
4.57k stars 1.12k forks source link

Can't get acess to the table in .docx file through python-docx api. #488

Closed alexbalandi closed 6 years ago

alexbalandi commented 6 years ago

Hello!

I've made a minimal example of docx file, containing a single table with the formatting I faced in a real document. When I try: test_doc = docx.Document('non_readable_table.docx') print(test_doc.tables) I get an empty list. All paragraphs are also empty. I'm not exactly familiar with xml stuff, that's why I use python-docx as some high-level api for the document so I can't really figure what's the problem here. I'm sorry in advance if this is not the issue with the library, but with my own skills.

I tried iterating over all objects as suggested here but to no avail: it yeilds a list of empty paragraphs and nothing more. I attach the minimal example .docx file. non_readable_table.docx

What is the correct way to handle such tables within python-docx api (if there is one)?

Regards,

Alex.

scanny commented 6 years ago

Your table is a graphical table, like those used in PowerPoint, not a native Word table. This is why it doesn't appear.

xies4 commented 2 months ago

Is there a way to read a graphical table using python docx? Thanks.

xies4 commented 2 months ago

Is there a way to read a graphical table using python docx? Thanks.

A solution has been posted here: https://stackoverflow.com/questions/78875922/how-to-read-and-input-data-into-a-table-graph-in-an-template-word-file-using-pyt/78876278#78876278