Preserve table format while reading and writing from existing docx to a new docx
Here is the code I am trying for the below table that is inside my demo.docx
but I am not getting the output in same format Need help to fix this so that I can copy this table in the same format to my new docx
ITEM
NEEDED
Books
1
Pens
3
Pencils
2
Highlighter
2 colors
Scissors
1 pair
Code I am using is below..
import docx
doc = docx.Document('demo.docx')
doc = docx.Document('demo.docx')
for table in doc.tables:
for row in table.rows:
for cell in row.cells:
for para in cell.paragraphs:
print para.text
I was going through Parsing of table from .docx file but again , I need to create table inside new docx , not sure how to do that .