using (WordprocessingDocument
wordDocument =
WordprocessingDocument.Create(filepath,
WordprocessingDocumentType.Document))
{
//
Add a main document part.
MainDocumentPart
mainPart = wordDocument.AddMainDocumentPart();
//
Create the document structure and add some text.
mainPart.Document = new Document();
Body
body = mainPart.Document.AppendChild(new Body());
Paragraph
para = body.AppendChild(new Paragraph());
Run
run = para.AppendChild(new Run());
RunProperties
runProperties = new RunProperties();
//font
family
RunFonts
font1 = new RunFonts()
{ Ascii = "Arial" };
run.AppendChild(font1);
//font
size
FontSize
fs = new FontSize();
fs.Val = "22";
runProperties.AppendChild(fs);
//Super script
//Super script
VerticalTextAlignment
v = new VerticalTextAlignment();
v.Val = VerticalPositionValues.Superscript;
runProperties.AppendChild(v);
run.AppendChild(runProperties);
run.AppendChild(new Text("Create text in body – CreateWordprocessingDocument using Superscript"));
mainPart.Document.Save();
wordDocument.Close();
}
No comments:
Post a Comment