using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Wordprocessing;
using System.IO.Packaging;
namespace OpenXMLConsole
{
class Program
{
static void Main(string[] args)
{
string path = @"E:\OpenXMLBreak.docx";
//// Creates the new instance of the WordprocessingDocument class from the specified file
//// WordprocessingDocument.Open(String, Boolean) method
//// Parameters:
//// string path - path is a string which contains the path of the document
//// bool isEditable
using (WordprocessingDocument doc = WordprocessingDocument.Create(path, WordprocessingDocumentType.Document))
{
//// Defines the MainDocumentPart
MainDocumentPart mainDocumentPart = doc.AddMainDocumentPart();
mainDocumentPart.Document = new Document();
Body body = mainDocumentPart.Document.AppendChild(new Body());
Paragraph para = body.AppendChild(new Paragraph());
Run run =para.AppendChild(new Run());
Text txt1 = new Text("Welcome!!!!!!");
Text txt2 = new Text("Welcome to SharePoint Blogs!!!!!!");
run.AppendChild(txt1);
run.AppendChild(new Break());
run.AppendChild(txt2);
mainDocumentPart.Document.Save();
}
}
}
}