How to set horizontal alignment in table

Posted by: david.sheppard on 15 February 2020, 8:43 pm EST

  • Posted 15 February 2020, 8:43 pm EST

    I 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.
  • Replied 16 February 2020, 8:27 pm EST

    Hi 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.

    https://www.grapecity.com/documents-api-word/docs/online/cell.html
    https://www.grapecity.com/documents-api-word/docs/online/GrapeCity.Documents.Word~GrapeCity.Documents.Word.CellPadding~Left.html


    Regards,
    Prabhat Sharma.
  • Replied 17 February 2020, 12:10 am EST

    Hello.

    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;


    Thanks,
    A
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels