Vb.net openxml Word文档中的文本中心对齐
我正在尝试使用开放式xml将格式应用于文本。我想添加粗体,18磅字体,并有它的中心 粗体和字体大小格式正确应用,但我无法使中心对齐正常工作。这是我第一次使用开放式XML,非常感谢您的帮助Vb.net openxml Word文档中的文本中心对齐,vb.net,openxml,openxml-sdk,Vb.net,Openxml,Openxml Sdk,我正在尝试使用开放式xml将格式应用于文本。我想添加粗体,18磅字体,并有它的中心 粗体和字体大小格式正确应用,但我无法使中心对齐正常工作。这是我第一次使用开放式XML,非常感谢您的帮助 Dim mainPart As MainDocumentPart = mydoc.AddMainDocumentPart() mainPart.Document = New Document() Dim body As New Body() Dim paragraph As New Paragraph() D
Dim mainPart As MainDocumentPart = mydoc.AddMainDocumentPart()
mainPart.Document = New Document()
Dim body As New Body()
Dim paragraph As New Paragraph()
Dim run_paragraph As New Run()
'we want to put that text into the output document
Dim text_paragraph As New Text("Executive Summary - " + name)
'Append elements appropriately.
'bold
Dim RunProperties As RunProperties = run_paragraph.AppendChild(New RunProperties())
Dim Bold As New Bold
Bold.Val = OnOffValue.FromBoolean(True)
Dim fontSize As New FontSize
fontSize.Val = "22"
RunProperties.AppendChild(fontSize)
RunProperties.AppendChild(Bold)
'center
Dim paragraphProperties As ParagraphProperties = run_paragraph.AppendChild(New ParagraphProperties())
Dim justification As New Justification
justification.Val = JustificationValues.Center
paragraphProperties.AppendChild(justification)
run_paragraph.AppendChild(text_paragraph)
paragraph.Append(run_paragraph)
body.Append(paragraph)
mainPart.Document.Append(body)
mainPart.Document.Save()
Response.Redirect("~/summaries/" + documentfilename)
尝试将
段落属性
添加到段落
对象(而不是运行段落
)
替换:
Dim paragraphProperties As ParagraphProperties = run_paragraph.AppendChild(New ParagraphProperties())
与:
Dim paragraphProperties As ParagraphProperties = paragraph.AppendChild(New ParagraphProperties())