Posted 15 February 2020, 8:43 pm ESTI can not find how to set the horizontal alignment of text in cells in a table. For example, I would like all of the text in the 3rd table column to be centered.
How to set horizontal alignment in table
Posted by: david.sheppard on 15 February 2020, 8:43 pm EST
Replied 16 February 2020, 8:27 pm ESTHi David,
There is no such class to set the properties at the column level and also there is no HorizontalAlignment property at cell level so you need to format the cells using Padding property to achieve the desired result.
Replied 17 February 2020, 12:10 am ESTHello.
General-purpose solution is to define paragraph.Format.Alignment for every column cell's paragraph.
Microsoft Word does the same thing when whole column is selected and alignment changed.
For few TableStyleOverride enum-defined columns it also can be solved using ConditionalStyle:
Style tablestyle = doc.Styles.Add("table style 1", StyleType.Table);
table.Style = tablestyle;
table.Format.StyleOptions = TableStyleOptions.LastColumn;
table.Style.Table.Conditionals[TableStyleOverride.LastColumn].ParagraphFormat.Alignment = ParagraphAlignment.Center;