the problem is solved
//Creates an instance of WordDocument class WordDocument document = new WordDocument(); document.Open("Table.docx", FormatType.Docx); WSection section = document.Sections[0]; WTable table = section.Tables[0] as WTable; //Accesses the instance of the first row in the table WTableRow row = table.Rows[0]; //Specifies the row height row.Height = 20; //Specifies the row height type row.HeightType = TableRowHeightType.AtLeast; //Accesses the instance of the first cell in the row WTableCell cell = row.Cells[0]; //Specifies the cell back ground color cell.CellFormat.BackColor = Color.FromArgb(192, 192, 192); //Specifies the same padding as table option as false to preserve current cell padding cell.CellFormat.SamePaddingsAsTable = false; //Specifies the left, right, top and bottom padding of the cell cell.CellFormat.Paddings.Left = 5; cell.CellFormat.Paddings.Right = 5; cell.CellFormat.Paddings.Top = 5; cell.CellFormat.Paddings.Bottom = 5; //Specifies the vertical alignment of content of text cell.CellFormat.VerticalAlignment = VerticalAlignment.Middle; //Disables the text wrap option to avoid displaying longer text on multiple lines cell.CellFormat.TextWrap = false; //Sets text direction for cell cell.CellFormat.TextDirection = TextDirection.VerticalBottomToTop; //Saves and closes the document instance document.Save("TableCellFormatting.docx", FormatType.Docx); document.Close(); |