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

Free Support Forum - aspose.com

Aspose word-To insert html which contains style class

Hi,


I have html string which contains table(not contains any other html tag) I am inserting into word document using documentBuilder.insertHtml() method.

Sometimes HTML string may contains the style class which is defined in external CSS file.

For Example:-String html=“ABCD” here title is style class.
so if i insert above html string into the word document that title class style will not be applied to row as i am not importing the CSS file while inserting into the word document.

So finally I want to apply the title class to the row in the table.so how i can achieve this.
there is any provision in aspose word to import the CSS files while inserting html to word file.

Please help.

Thanks.
Chandrashekhar

Hi Chandrashekhar,


Thanks for your inquiry. Please try using the following code:
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

String html = readFile(getMyDir() + “HTMLPage1.html”, Charset.forName(“UTF8”));
String css = readFile(getMyDir() + “StyleSheet1.css”, Charset.forName(“UTF8”));

String finalHtml = “Document Title” +
css + “” +
html + “”;

builder.insertHtml(finalHtml);

doc.save(getMyDir() + “15.6.0.docx”);

I hope, this helps.

Best regards,