//Creates Word document instance
WordDocument document = new WordDocument();
//Appends a section with an empty paragraph
document.EnsureMinimal();
//Adds the table to the last section
WTable table = document.LastSection.AddTable() as WTable;
//Sets the table with 3 rows and 3 columns
table.ResetCells(3, 3);
//Applies table built in style - TableList3
table.ApplyStyle(BuiltinTableStyle.TableList3);
//Applies padding to complete table
table.TableFormat.Paddings.Left = 10;
//Disables the MS Word flag 'Same as the whole table' option
table.Rows[0].Cells[0].CellFormat.SamePaddingsAsTable = false;
//Applies the padding to the current row via cell
table.Rows[0].Cells[0].CellFormat.Paddings.Left = 5;
//Saves the document
document.Save("Sample.docx");
//Closes the document instance
document.Close(); |