Hi,
you can
export to Word in ASP.NET or Windows application with this
C# / VB.NET Word library.
Here is a sample C# code how to export DataGridView to Word file with
.NET mail merge functionality:
ComponentInfo.SetLicense("FREE-LIMITED-KEY");
var document = new DocumentModel();
document.Sections.Add(
new Section(document,
new Table(document,
new TableRow(document,
new TableCell(document,
new Paragraph(document, "Name")),
new TableCell(document,
new Paragraph(document, "Surname"))),
new TableRow(document,
new TableCell(document,
new Paragraph(document,
new Field(document, FieldType.MergeField, "RangeStart:People"),
new Field(document, FieldType.MergeField, "Name"))),
new TableCell(document,
new Paragraph(document,
new Field(document, FieldType.MergeField, "Surname"),
new Field(document, FieldType.MergeField, "RangeEnd:People")))))));
document.Save("TemplateDocument.docx", SaveOptions.DocxDefault);
document = DocumentModel.Load("TemplateDocument.docx", LoadOptions.DocxDefault);
document.MailMerge.ExecuteRange("People", dataGridView.DataSource);
document.Save("Document.docx", SaveOptions.DocxDefault);