Version

About WinGridWordWriter

When used with the WinGridWordWriter™ component, the WinGrid™ control is able to write data into a new Microsoft® Word document. Exporting to Word is a process similar to printing grid data, where you have control over how Layouts and Appearances are applied to the data before export. Additionally you are able to control which data is included or excluded in the export. Exporting is not limited to grid data; headers, column groupings, summary rows, and more may all be included in the export.

To write WinGrid data into a new Word document, the WinGridWordWriter component is first added to the application. The WinGridWordWriter component requires reference to two assemblies:Infragistics.Win.UltraWinGrid.WordWriter and Infragistics.Documents.IO. This component allows you to export based on the new WordDocumentWriter object within the Infragisitcs.Documents.IO assembly. With the WordDocumentWriter object the UltraWinGrid control is directly exported to a file without creating the document in memory. This approach, known as using a streamer, is valuable because the process uses much less RAM to avoid memory issues caused by exporting large data sets.

Note
Note

The streamer only creates new documents therefore you cannot export the data from the WinGrid control to an existing Word document.

Writing grid data into a Word document is initiated by invoking the Export method of the WinGridWordWriter component, passing it the WinGrid control that you wish to export and the file name or stream or a WordDocumentWriter object as overloads.

In C#:

using Infragistics.Documents.Word;
// Call the Export method on WinGridWordWriter and
// pass the Grid control and file name as parameters.
this.ultraGridWordWriter1.Export(ultraGrid1, "C:\Samples_Projects\GridDataInWord.docx");

In Visual Basic:

Imports Infragistics.Documents.Word
' Call the Export method on WinGridWordWriter and
' pass the Grid control and file name as parameters.
Me.ultraGridWordWriter1.Export(ultraGrid1, "C:\Samples_Projects\GridDataInWord.docx")

Additionally, the WinGridWordWriter component exposes various events such as:

These events help you gain fine-grained control over the export process.