May-28-2019, 06:38 PM
#!/usr/bin/python3 from docx import Document from docx.shared import Inches document = Document() records = ( ('A', 'C'), ('B', 'C'), ) table = document.add_table(rows=1, cols=2) hdr_cells = table.rows[0].cells hdr_cells[0].text = 'start' hdr_cells[1].text = 'end' for c0, c1 in records: row_cells = table.add_row().cells row_cells[0].text = c0 row_cells[1].text = c1 document.save('demo.docx')