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

Free Support Forum - aspose.com

Cell Horizontal allignment problem

Hi,

I have one table containing 5 cell out of which 1,3 and 5 cell needs horizontally center allignement and other cell horizontally left alignment.

when i used code

switch(columnNo)

{

case 1:

case 3:

case 5:

DocBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Center ;

break ;

case 4:

case 2:

DocBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Left ;

break ;

}

DocBuilder.InsertCell();

DocBuilder.Write(strText);

but still it is not displaying in proper alignment.

Can you please suggest how and where should i give this alignment so that it give me proper result ?

Hi

Thanks for your inquiry. Try to use the following code.

string strText = "test";

builder.CellFormat.Width = 100;

for (int i = 1; i <= 5; i++)

{

builder.InsertCell();

switch (i)

{

case 1:

case 3:

case 5:

builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;

break;

case 4:

case 2:

builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;

break;

}

builder.Write(strText);

}

builder.EndRow();

builder.EndTable();

I hope that it will help you to solve your problem.

Best regards.

ya its working…Thanks a lot…