Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net openxml Word文档中的文本中心对齐_Vb.net_Openxml_Openxml Sdk - Fatal编程技术网

Vb.net openxml Word文档中的文本中心对齐

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

我正在尝试使用开放式xml将格式应用于文本。我想添加粗体,18磅字体,并有它的中心

粗体和字体大小格式正确应用,但我无法使中心对齐正常工作。这是我第一次使用开放式XML,非常感谢您的帮助

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())