You can use Open XML which works fine
(can be done with Office Interop too, but it needs Office to be installed)
Basic sample : Create a word processing document by providing a file name
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi,
How to create one .docx file using C sharp?
You can use Open XML which works fine
(can be done with Office Interop too, but it needs Office to be installed)
Basic sample : Create a word processing document by providing a file name
Install the following NuGet package DocumentFormat.OpenXml.
Try creating a new document
using (var document = WordprocessingDocument.Create(fileName, WordprocessingDocumentType.Document))
{
MainDocumentPart mainPart = document.AddMainDocumentPart();
mainPart.Document = new Document();
mainPart.Document.AppendChild(new Body());
mainPart.Document.Save();
}
The above is taken from Office Word Basic operations: Open XML SDK 2.5 Office Word documents with source code in the following repository project.
EDIT: Code sample to create a new document and write a single paragraph.