【发布时间】:2019-10-24 22:29:27
【问题描述】:
我尝试将段落添加到居中的表格单元格中,但它不起作用。 我在互联网和stackoverflow上做了很多研究,但没有幸运。 1.尝试使用Justification添加中心并添加到段落中,没有奏效 2.尝试使用 Justification 添加中心并添加到 RunProperties 也没有 owk 这是我在 vb.net 中编写的代码
Function SetFormatHeaderText(txt) As Paragraph
Dim prg As Paragraph = New Paragraph()
Dim run As New Run()
Dim t As Text = New Text(txt)
Dim rPr As RunProperties = New RunProperties()
Dim fSize As FontSize = New FontSize() With {.Val = "22"}
Dim fName As RunFonts = New RunFonts With {.Ascii = "Calibri"}
'Dim jf As Justification = New Justification With {.Val = JustificationValues.Center}
Dim b As Bold = New Bold()
'rPr.Append(jf)
'prg.AppendChild(Of Justification)(New Justification() With {.Val = JustificationValues.Center})
rPr.Append(fSize)
rPr.Append(fName)
rPr.Append(b)
run.Append(rPr)
run.Append(t)
prg.Append(run)
Return prg
End Function
这是 rpt.Append(jf) 的输出 发行日期
【问题讨论】:
-
您是否尝试在 Open XML sDK 生产力工具中打开一个(小)示例文档并查看生成该文档的代码?马上,我想说您需要在 Paragraph Properties (
pPr) 中指定段落格式(对齐方式) -
谢谢辛迪,我成功了