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

Free Support Forum - aspose.com

[Tables Alignment] Issue between Write and Writeln

Hey everyone,

I’m trying to build a new table using Aspose.Words, in .NET (Visual Basic) project.
I built the table without any huge issue, but i’ve some issue with some details.

When i’m using :
Builder.ParagraphFormat.Alignment = ParagraphAlignment.Center
Builder.WriteLn("my text")
I have a new cell, with center alignement and a line break at the end (paragraph break), which makes my cell bigger than i expected, like this :

I tried using Write like this :
Builder.ParagraphFormat.Alignment = ParagraphAlignment.Center
Builder.Write("my text")

No line break, perfect, but alignement is not applied.

I tried with WriteLn and removing ParagraphBreaks, but Alignement got removed too, like this :
Builder.ParagraphFormat.Alignment = ParagraphAlignment.Center
Builder.WriteLn("my text")
Builder.CurrentParagraph.ParentNode.Range.Replace("&p", "")

So i’m trying to remove this lineBreak after WriteLn, saving my center alignement.
Is there a way to deal with paragraph without this huge line break ?

Thanks a lot

You can achieve your requirement by replacing Writeln with Write method in above code snippet. In case you are using old version of Aspose.Words for .NET, we suggest you please use the latest version of Aspose.Words for .NET 21.8.

If you still face problem, please attach the following resources here for testing:

  • Your input Word document if you are using any.
  • Please attach the output Word file that shows the undesired behavior.
  • Please attach the expected output Word file that shows the desired behavior.
  • Please create a standalone console 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 will start investigation into your issue and provide you more information. Thanks for your cooperation.

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

Hey Tahir,
Thanks a lot for your answer.

I’m using Aspose.Words .NET 20.5 version, i’ll update my version.

I tried to use Write method (my second attempt). But when Write is using, i can’t get alignment.
I’ll attach all of this asap.



Please share the requested resources here for testing. We will investigate the issue and provide you more information on it.

Hey @tahir.manzoor

Thanks for your answer, and sorry about delay.

I built a console app which is able to generate his .docx and write a new table with 3 rows, 3 cells in each row.
In folder Issue, i put a Word example, and a screenshot of issue.
I installed ASPOSE WORDS 21.5, my subscription can’t bring me more.

Each row has a different way of writing cells.

You can install a new licence file on LIC folder, then you could generate and create your own Word with my issue.

I couldn’t direct upload, so i made a wetransfer link : https://we.tl/t-FccwClSU4T

Thanks for your time,


In ResetParameters method, you are setting the current paragraph alignment as Left. So, you are getting the expected behavior of Aspose.Words.

Please remove following line of code from ResetParameters to get the desired output.

B.ParagraphFormat.Alignment = ParagraphAlignment.Left

If you do not want to remove this line of code, please add following code snippet after the call of ResetParameters method.

ResetParameters(B, DefaultFontSize)
If B.CurrentParagraph.ParentNode.NodeType = NodeType.Cell Then
    B.CurrentParagraph.ParagraphFormat.Alignment = ParagraphAlignment.Center
End If
1 Like

Alright, just tested it on the console app, works perfectly.
I though that if i wasn’t setting back, alignement will do anything else.

Thanks a lot Tahir !