import aspose.words as aw import datetime import aspose.pydrawing as drawing # Load the license wordLic = aw.License() wordLic.set_license("Aspose.Total.lic") # Open MS Word Document MSWordDocument = aw.Document("WordWithTable.docx") # Get the Table by index tableToAddRowsTo = MSWordDocument.first_section.body.tables[0] # Create a new Row class object row = aw.tables.Row(MSWordDocument) # Add five Cells to Row's cells collection for i in range(5): cell = aw.tables.Cell(MSWordDocument) cell.append_child(aw.Paragraph(MSWordDocument)) cell.first_paragraph.runs.add(aw.Run(MSWordDocument, "Text in Cell " + str(i))) row.cells.add(cell) # Insert new Row after the first Row tableToAddRowsTo.rows.insert(1, row) MSWordDocument.save("TableWithAdditionalRows.docx") print ("Rows added to Word table successfully")