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

Free Support Forum - aspose.com

TH Tags appearing as Bold and Centered when transforming to Word Document

Hello,

Whenever a

tag is used in an html table that is then transformed into a Word Document, the cell font is always Bold and Centered. The font takes on other settings such as underlining fine, but the font is always bolded and the alignment is always centered.

Is there some way of changing this behavior or is this a known issue with Words?

Hi David,


Thanks for your inquiry.

By default the text in a th element is bold and centered while the text in a td element is regular and left-aligned. Please see the following code snippet for the desired custom formatting:

Document
doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

StringBuilder sb = new StringBuilder();
sb.Append("");
sb.Append("
");
sb.Append("<th align=‘Left’>Month");
sb.Append("<th align=‘Left’>Savings");
sb.Append("
");
sb.Append("
");
sb.Append(
);
sb.Append("
");
sb.Append("
");
sb.Append("
January $100
"
);

builder.InsertHtml(sb.ToString());
doc.Save(@“C:\test\toHTML.docx”);

I hope, this will help.

Best Regards,