Free Support Forum - aspose.com

Align (center or right) in a table cell

Hi

Is the only way to align value in cells of a table is to use HTML or is there another that I am missing?

Hi

Thanks for your inquiry. You can use ParagraphFormat.Alignment. For example see the following code.

//Create document

Document doc = new Document();

//Create DocumentBuilder

DocumentBuilder builder = new DocumentBuilder(doc);

//Configure builder

builder.CellFormat.Width = 100;

builder.CellFormat.Borders.LineStyle = LineStyle.Single;

builder.CellFormat.Borders.Color = Color.White;

//Insert Celll

builder.InsertCell();

//Set aligment

builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;

//Inset value

builder.Write("Center");

builder.InsertCell();

builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;

builder.Write("Left");

builder.InsertCell();

builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;

builder.Write("Right");

builder.InsertCell();

builder.EndRow();

builder.EndTable();

//Save document

doc.Save("out.doc");

Also see the following link.
http://www.aspose.com/Products/Aspose.Words/Api/Inserting_a_Table.html

Hope this helps.

Best regards.

It is working. Thanks