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

Free Support Forum - aspose.com

How to align center of a column text and another as "left" align

I have this code, i want to align a column (width 20% ) text to center in a cell.
i tried to put center alignment like this but this put whole table alignment to centre.

docBuilder.InsertCell();
docBuilder.CellFormat.HorizontalMerge = CellMerge.None;
docBuilder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
docBuilder.Font.Bold = true;
docBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Center; //added on 13 Apr to Align centerd
docBuilder.CellFormat.Width = 20;
if (siteAssessment.Status.ToLower() == “no”)
{
docBuilder.CellFormat.Shading.BackgroundPatternColor = System.Drawing.ColorTranslator.FromHtml("#D99594");
docBuilder.Font.Color = System.Drawing.Color.Black;
}
else
{
docBuilder.CellFormat.Shading.BackgroundPatternColor = System.Drawing.ColorTranslator.FromHtml("#255077");
docBuilder.Font.Color = System.Drawing.Color.White;
}
docBuilder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);
docBuilder.Write(siteAssessment.Status.ToUpper());
docBuilder.EndRow();

any suggestion??

@Gauravmiri,

Thanks for your inquiry. You are setting the alignment of paragraph using DocumentBuilder.ParagraphFormat.Alignment. Please call DocumentBuilder.ParagraphFormat.ClearFormatting() before writing the text into new cell.

Thank you.
This worked for me. :slight_smile: