Printing Nested Tables
See original GitHub issueHI there, I would like to check if it is possible to print nested tables out using this library? I tried to work on it but however, it just prints the nested table as empty.
from docx import Document
f = open('a.docx', 'rb')
doc = Document(f)
table = doc.tables[0]
data = []
keys = None
for i, row in enumerate(table.columns):
text = (cell.text for cell in row.cells)
if i == 0:
keys = tuple(text)
continue
row_data = dict(zip(keys, text))
data.append(row_data)
print (data)
x = 0
for i in doc.paragraphs:
if x < 20:
print (i.text)
else:
break
x = x + 1
f.close()
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Nested table issue while printing document - Stack Overflow
Try the following css (this only helps if you have a very plain thead an only one aswell): thead { display: table-header-group }...
Read more >PDF/Print with nested tables — DataTables forums
Hello I'm using the feature of export PDF and print button, this works weel since it produce the PDF or launch the print...
Read more >Printing nested tables in R – bridging between the {reshape ...
This post shows how to print a prettier nested pivot table, created using the {reshape} package (similar to what you would get with ......
Read more >Oracle PL/SQL - Printing Elements of Sparse Nested Table
The following code uses FIRST, NEXT, and a WHILE LOOP statement to print the elements of an associative array. It prints the elements...
Read more >Nested Loops C# - Printing Tables - YouTube
# NestedLoops #CsharpLoops Nested Loop C# - Printing Tables Like, Share, And Subscribe | Professor Saad Yousuf … Show more. Show more ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I think I would extract the bit about navigating a single table for its paragraphs and make that recursive:
That way your specific use for those paragraphs (printing in this case) is up to the caller and the
iter_table_paragraphs()function is more general purpose. You could use it to inspect each paragraph for example, or maybe inspect each paragraph style or search for a word.@richylyq
python-docxsupports nested tables just fine, you just need to look for them as tables. They are not part of the text of a cell. Something like: