Arb*_*liu 3 c# ms-word openxml openxml-sdk
我正在尝试将段落居中对齐,但对该段落没有任何影响。我正在使用 OpenXml。下面是代码:
//paragraph properties
ParagraphProperties User_heading_pPr = new ParagraphProperties();
//trying to align center a paragraph
Justification justification1 = new Justification() { Val = JustificationValues.Center };
// build paragraph piece by piece
Text text = new Text(DateTime.Now.ToString() + " , ");
Text text1 = new Text(gjenerimi + " , ");
Text text2 = new Text(merreshifren());
var run = new Run();
run.Append(text,text1,text2);
Paragraph newParagraph = new Paragraph(run);
User_heading_pPr.Append(justification1);
newParagraph.Append(User_heading_pPr);
Run Code Online (Sandbox Code Playgroud)
这是我尝试将段落居中对齐的方法。
颠倒分配文本和段落属性的顺序:
User_heading_pPr.Append(justification1);
Paragraph newParagraph = new Paragraph(User_heading_pPr);
newParagraph.Append(run);
Run Code Online (Sandbox Code Playgroud)
在有效且格式良好的 Word Open XML 中,段落属性必须先于运行。因此,您必须以相同的方式构建 Open XML 文档。
这与对象模型有点不同,我们通常用来处理它们的方式 - 顺序很重要!
| 归档时间: |
|
| 查看次数: |
7270 次 |
| 最近记录: |