Free Support Forum - aspose.com

Table cell alignment is not correct for tables using Word table styles

Hello,


When processing the table in the attached file the alignment of the first paragraph of the cells in the first column of the table (cell.FirstParagraph.ParagraphFormat.Alignment) are centred when they are right aligned in the word document.

The table has a design Table style applied where for the whole table it has centre alignment and for the first column it has right alignment.

Could you please advise how we can get the correct alignment for these cells?

Thank you
Polly

<span style=“color: rgb(22, 35, 58); font-family: “Segoe UI”, “Helvetica Neue”, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20.0004px; background-color: rgb(255, 255, 255);”>To clarify, this is an issue when using a customized table style where the formatting of the table has centre aligned tables, but the first columns formatting is right aligned.<br style=“box-sizing: border-box; color: rgb(22, 35, 58); font-family: “Segoe UI”, “Helvetica Neue”, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20.0004px; background-color: rgb(255, 255, 255);”><span style=“color: rgb(22, 35, 58); font-family: “Segoe UI”, “Helvetica Neue”, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20.0004px; background-color: rgb(255, 255, 255);”>

<span style=“color: rgb(22, 35, 58); font-family: “Segoe UI”, “Helvetica Neue”, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20.0004px; background-color: rgb(255, 255, 255);”>We’ve found the Cell.CellFormat.VerticalAlignment property, and this seems to work when applying to individual cells, but doesn’t work when only applied to the table style. We can’t find an equivalent Cell.CellFormat.HorizontalAlignment property.
Hi there,

Thanks for your inquiry. In case you are using an older version of Aspose.Words, we would suggest you please upgrade to the latest version of Aspose.Words for .NET 17.4. Please use following code example to get the alignment value.

Document doc = new Document(MyDir + "TableWithTableStyle.docx");

Table table = (Table)doc.GetChild(NodeType.Table, 0, true);

Console.WriteLine(table.FirstRow.FirstCell.CellFormat.VerticalAlignment); // Returns Top

Console.WriteLine(table.FirstRow.FirstCell.FirstParagraph.ParagraphFormat.Alignment); // Returns Right