You can also try our third-party library GemBox.Document .
Here is an example of C # code with which you can create a Word Word document (DOCX) and use mail merge . import data into it:
var document = new DocumentModel(); document.Sections.Add( new Section(document, new Paragraph(document, "Agenda List:"), new Paragraph(document, new Field(document, FieldType.MergeField, "RangeStart:Agendas"), new Field(document, FieldType.MergeField, "Subject") { CharacterFormat = { Bold = true } }, new SpecialCharacter(document, SpecialCharacterType.LineBreak), new SpecialCharacter(document, SpecialCharacterType.Tab), new Field(document, FieldType.MergeField, "Description")), new Paragraph(document, new Field(document, FieldType.MergeField, "RangeEnd:Agendas")))); var agendas = new object[] { new { Subject = "First agenda subject", Description = "First agenda description." }, new { Subject = "Second agenda subject", Description = "Second agenda description." } }; document.MailMerge.Execute(agendas, "Agendas"); document.Save("Agendas.docx");
You can also easily save a Word report in ASP.NET .
source share