Filling dynamic values in word document table using python
up vote
0
down vote
favorite
I am trying to auto fill a word document template with dynamically generating values, using python-docx.
I need to add a row in between two rows in a table. I researched on it but unfortunately I could only add a row just at the end of the table. I'm stuck with this problem right now.
The code I tried:
from docx import Document
file = 'test1.docx'
document = Document(file)
tables = document.tables
row_cells = tables[0].add_row().cells
row_cells[0].text = ""
row_cells[1].text = "Application name"
document.save("test1out.docx")
This code adds a row to the end of table only.
Here is the template document I tried.
test1.docx
Here I'm trying to insert a row between 4th and 5th row.
Thanks in advance.
python ms-word python-docx
add a comment |
up vote
0
down vote
favorite
I am trying to auto fill a word document template with dynamically generating values, using python-docx.
I need to add a row in between two rows in a table. I researched on it but unfortunately I could only add a row just at the end of the table. I'm stuck with this problem right now.
The code I tried:
from docx import Document
file = 'test1.docx'
document = Document(file)
tables = document.tables
row_cells = tables[0].add_row().cells
row_cells[0].text = ""
row_cells[1].text = "Application name"
document.save("test1out.docx")
This code adds a row to the end of table only.
Here is the template document I tried.
test1.docx
Here I'm trying to insert a row between 4th and 5th row.
Thanks in advance.
python ms-word python-docx
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am trying to auto fill a word document template with dynamically generating values, using python-docx.
I need to add a row in between two rows in a table. I researched on it but unfortunately I could only add a row just at the end of the table. I'm stuck with this problem right now.
The code I tried:
from docx import Document
file = 'test1.docx'
document = Document(file)
tables = document.tables
row_cells = tables[0].add_row().cells
row_cells[0].text = ""
row_cells[1].text = "Application name"
document.save("test1out.docx")
This code adds a row to the end of table only.
Here is the template document I tried.
test1.docx
Here I'm trying to insert a row between 4th and 5th row.
Thanks in advance.
python ms-word python-docx
I am trying to auto fill a word document template with dynamically generating values, using python-docx.
I need to add a row in between two rows in a table. I researched on it but unfortunately I could only add a row just at the end of the table. I'm stuck with this problem right now.
The code I tried:
from docx import Document
file = 'test1.docx'
document = Document(file)
tables = document.tables
row_cells = tables[0].add_row().cells
row_cells[0].text = ""
row_cells[1].text = "Application name"
document.save("test1out.docx")
This code adds a row to the end of table only.
Here is the template document I tried.
test1.docx
Here I'm trying to insert a row between 4th and 5th row.
Thanks in advance.
python ms-word python-docx
python ms-word python-docx
asked 2 days ago
AlfyFaisy
295
295
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53225040%2ffilling-dynamic-values-in-word-document-table-using-python%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password