Document doc = new Document(filePath + @"20080.docx");
Section sec = doc.Sections[0];
ParagraphStyle style = new ParagraphStyle(doc);
style.Name = "MyCustomStyle";
style.CharacterFormat.FontSize = 20;
style.CharacterFormat.Bold= true;
doc.Styles.Add(style);
Table table = sec.Tables[0] as Table;
foreach(TableRow row in table.Rows )
{
foreach(TableCell cell in row.Cells)
{
foreach(Paragraph par in cell.Paragraphs)
{
par.ApplyStyle("MyCustomStyle");
}
}
}
doc.SaveToFile("T20080.docx");Document doc = new Document();
Section section = doc.AddSection();
TableStyle tableStyle = (TableStyle)doc.Styles.Add(StyleType.TableStyle, "TestTableStyle1");
tableStyle.HorizontalAlignment = RowAlignment.Center;
tableStyle.Borders.Color = Color.Blue;
tableStyle.Borders.BorderType = BorderStyle.Single;
Table table = section.AddTable();
table.ResetCells(1, 1);
table.Rows[0].Cells[0].AddParagraph().AppendText("Aligned to the center of the page");
table.PreferredWidth = PreferredWidth.FromPoints(300);
table.ApplyStyle(tableStyle);
section.AddParagraph().AppendText(" ");
tableStyle = (TableStyle)doc.Styles.Add(StyleType.TableStyle, "TestTableStyle2");
tableStyle.LeftIndent = 55;
tableStyle.Borders.Color = Color.Green;
tableStyle.Borders.BorderType = BorderStyle.Single;
table = section.AddTable();
table.ResetCells(1, 1);
table.Rows[0].Cells[0].AddParagraph().AppendText("Aligned according to left indent");
table.PreferredWidth = PreferredWidth.FromPoints(300);
table.Format.Style = tableStyle;
doc.SaveToFile(outputDocxFile1, FileFormat.Docx);