In this blog you will see how to create a new document using Open XML SDK 2.0.
Assembly:
DocumentFormat.OpenXml.dll
Namesapces:
using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Wordprocessing; using System; using System.Collections.Generic; using System.Linq; using System.Text; using DocumentFormat.OpenXml; using DocumentFormat.OpenXml.Packaging; using DocumentFormat.OpenXml.Wordprocessing; namespace OpenXMLConsole { class Program { static void Main(string[] args) { //// filepath is a string which contains the path where the new document has to be created string filePath = @"E:\OpenXMLTest.docx"; using (WordprocessingDocument doc = WordprocessingDocument.Create(filePath, WordprocessingDocumentType.Document)) { //// Creates the MainDocumentPart and add it to the document (doc) MainDocumentPart mainPart = doc.AddMainDocumentPart(); mainPart.Document = new Document( new Body( new Paragraph( new Run( new Text("Hello World!!!!!"))))); } } } }
Code:

jayeshg goswamiPosted Oct 3, 2019, 7:47 AM
Hi Vijai, Its useful, and i try it but when i merge multiple doc file into one then its merge but not maintain contents properly. like doc file have 5 page but after merge generated file have 7 page with extra spaces and paragraph, ? Thanks in advance for help
venkadesh sPosted Jul 10, 2013, 8:30 AM
How to modify the web address of the Hyperlink in the word document??
Ozan CoeruetPosted May 8, 2012, 4:04 AM
Hi Vijai. Thank you for the Tutorial. Can i somehow add a complete HTML Code to design my Word-Document? Found it: http://notesforhtml2openxml.codeplex.com/documentation?referringTitle=ImageProcessing