Importar imagens utilizando Python docx. Encontrado alguma ajuda de post antigo, mas incapaz de convertê-lo em uma linha 3, mesa de col 2.
from docx import Document
document = Document()
tables = document.tables
table = document.add_table(rows=1, cols=2)
row_cells = table.add_row().cells
**for i, image in enumerate(['image1.jpg', 'image2.jpg']):
paragraph = row_cells[i].paragraphs[0]**
run = paragraph.add_run()
run.add_picture(image)
document.save('doc.docx')
Eu adaptei-lo para ...
document = Document()
tables = document.tables
table = document.add_table(rows=3, cols=2)
table.style = 'Table Grid'
row_cells = table.add_row().cells
Inc1 = ['1.jpg', '2.jpg','1.jpg', '2.jpg','1.jpg', '2.jpg']
length = len (Inc1)
for i in range(length):
for j in table.rows:
for k in table.columns:
paragraph = table.add_row().cells[i].paragraphs[0]
run = table.add_row().cells[i].paragraphs[0].paragraph.add_run()
run.add_picture('1.jpg', width = Inches(1))
document.save('test.docx')