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

Free Support Forum - aspose.com

I am using the aspose word api in one of my project

i got the below problem i am using the merge field concept in my project so the problem is as follows i am displaying data in the table format using merge fields so one of my table cell contains the html data so the question is how to display that html data with its formats in that particuler cell

Hi Burepalli,

Thanks for your inquiry. In your case, I suggest you to use IFieldMergingCallback interface to achieve your requirements. Please read following documentation links for your kind reference.

This code example shows how to mail merge HTML data into a document. Hope this helps you. If you still face problem, please attach your input Word document here for testing. We will then provide you more information on this along with code.

// File ‘MailMerge.InsertHtml.doc’ has merge field named ‘htmlField1’ in it.
// File ‘MailMerge.HtmlData.html’ contains some valid Html data.
// The same approach can be used when merging HTML data from database.
public void MailMergeInsertHtml()
    Document doc = new Document(MyDir + "MailMerge.InsertHtml.doc");
    // Add a handler for the MergeField event.
    doc.MailMerge.FieldMergingCallback = new HandleMergeFieldInsertHtml();
    // Load some Html from file.
    StreamReader sr = File.OpenText(MyDir + "MailMerge.HtmlData.html");
    string htmltext = sr.ReadToEnd();
    // Execute mail merge.
    doc.MailMerge.Execute(new string[] { "htmlField1" }, new string[] { htmltext });
    // Save resulting document with a new name.
    doc.Save(MyDir + "MailMerge.InsertHtml Out.doc");
private class HandleMergeFieldInsertHtml : IFieldMergingCallback
    // / 

    // / This is called when merge field is actually merged with data in the document.
    // / 
    void IFieldMergingCallback.FieldMerging(FieldMergingArgs e)
        // All merge fields that expect HTML data should be marked with some prefix, e.g. ‘html’.
        if (e.DocumentFieldName.StartsWith("html"))
            // Insert the text for this merge field as HTML data, using DocumentBuilder.
            DocumentBuilder builder = new DocumentBuilder(e.Document);
            // The HTML text itself should not be inserted.
            // We have already inserted it as an HTML.
            e.Text = "";
    void IFieldMergingCallback.ImageFieldMerging(ImageFieldMergingArgs e)
        // Do nothing.

Hi Tahir Manzoorv,
Thank you so much it worked.
Burepalli V S Rao.

Hi Burepalli,

Thanks for your feedback. Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.