How to Text Alignment in Table Cell

Hi.
I am able to create table, insert cell but unable to do Cell Text Alignment to Center. I am using this code.

builder.startTable();
builder.insertCell();
builder.getCellFormat().setVerticalAlignment(CellVerticalAlignment.*CENTER*);
builder.writeln("Product");

Sunil

Hi
Thanks for your inquiry. You should set alignment of paragraph. Please see the following code:

builder.insertCell();
builder.getParagraphFormat().setAlignment(ParagraphAlignment.CENTER);
builder.write("value");

Hope this helps.
Hope this helps.
Best regards.

Thanks Alexy.
I have confusion , How user will come to know that what will be aligned through CellFormat and What will be through paragraph.
Regards.
Sunil

Hi
Thanks for your inquiry. Please see the following link to learn more about Aspose.Words.Document object model.
https://docs.aspose.com/words/net/aspose-words-document-object-model/
As you can see table cells contains paragraphs. So if you need to change alignment of text you should use ParagraphFormat.Alignment.
Best regards.

If you want to align text to center vertically, please follow the bellow code:

cell.getCellFormat().setVerticalAlignment(CellVerticalAlignment.CENTER );

Note:
Please use CellVerticalAlignment.CENTER, not VerticalAlignment.CENTER.