What do you mean by "content"? Are there some specific requirements?
Below is the code for generating a simplest "Hello World" .docx document:
public static void CreateWordMLDocument() { string file = "CreateWordMLDocument.docx";
// Create a Wordprocessing document. using (WordprocessingDocument package = WordprocessingDocument.Create(file, DocumentFormat.OpenXml.WordprocessingDocumentType.Document)) { // Add a new main document part. package.AddMainDocumentPart();
// Create the Document DOM. package.MainDocumentPart.Document = new Document( new Body( new Paragraph( new Run( new Text("Hello World!")))));
// Save changes to the main document part. package.MainDocumentPart.Document.Save(); } }
btw, there are some learning resources:
Also, could you tell me what solution are you going to implement? Thanks!
I see. SDK cannot automatically refresh the content for you, if there's any change in your document.
You need to open the document via app to recalculate the right postion of the items in the content.