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

Free Support Forum - aspose.com

Export Gridview to Word


I’m new to this forum. Before going forward with Aspose I wanted to do 3 tests to see if this soft is what we want. Adding text and image to a word document is ok so far but what about a gridview ?

I’m far from understanding all the subtilities of Aspose.Word and did not succeed to export a gridview like something I used to do :

Dim oStringWriter As New System.IO.StringWriter()
Dim oHtmlTextWriter As New System.Web.UI.HtmlTextWriter(oStringWriter)

Coul you please show me an exemple with Aspose.word ?

Something similar to that should work I guess but at the moment I’m just having the gridview html code reproduced in the word document :

Dim doc As Document = New Document("Document.doc")
doc.MailMerge.Execute(New String() {"toto"}, New Object() {oStringWriter.ToString()})
doc.Save("Report Out.doc", SaveFormat.Doc, SaveType.OpenInBrowser, Response)

Thank you

Thanks for your inquiry. In this case oStringWriter.ToString() returns HTML string. So you should use InsertHtml method for inserting this HTML into the document. For example see the following code:

System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
string gridViewHtml = oStringWriter.ToString();
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
doc.Save("out.doc", SaveFormat.Doc, SaveType.OpenInBrowser, Response);

You should use MergeField event handler if you need to insert HTML during mail merge. See the following link for more information.
Hope this helps.
Best regards.

Thank you for your fast answer.

Works perfect, this tool is amusing ;p

this link offers no help i would like to see this example can you provide since the doc does not seem to have one


Thanks for your request and my apologizes for inconvenience. The link was broken after refactoring our documentation some time ago. Here is correct link to this article:
Hope this helps. Please let me know if you need more assistance, I will be glad to help you.
Best regards.