We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Set horizontal cell alignment for single cell

I’m using aspose words to draw a table in a document.
The table is not too complex, just some merged cells and some border styling.

What I’m struggling with is to horizontally align the text on the last cell on each row to the right. After aligning the first cell, all following cells on all rows are aligned to the right as well. This how i align the content:

row.getLastCell().getFirstParagraph().getParagraphFormat().setAlignment(ParagraphAlignment.RIGHT);

The problem is probably because the table is within one paragraph. Can you help me to align just a single table cell?

I have another problem with setting the cell width. If i set a cell width, the whole table kind of falls apart:

table.getRows().get(1).getFirstCell().getCellFormat().setWidth(1.0);

What am i doing wrong here?

@Jonas_D,

Thanks for your inquiry. To ensure a timely and accurate response, please attach the following resources here for testing:

  • Your input Word document.
  • Please attach the output Word file that shows the undesired behavior.
  • Please create a simple Java application (source code without compilation errors) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we’ll start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip and upload them.