具有多个项目符号字符的OpenXMl项目符号列表
本文关键字:符号 项目 OpenXMl 列表 字符 | 更新日期: 2023-09-27 18:13:58
My Expected out is
● AA
► BBB
■ CCC
我已经尝试了很多,但得到这样的输出
● AA
● BBB
● CCC
我的代码是
Document document1 = new Document();
document1.AddNamespaceDeclaration("w", "http://schemas.openxmlformats.org/wordprocessingml/2006/main");
Body body1 = new Body();
Paragraph paragraph3 = new Paragraph();
ParagraphProperties paragraphProperties1 = new ParagraphProperties();
ParagraphStyleId paragraphStyleId1 = new ParagraphStyleId(){ Val = "ListParagraph" };
Shading shading1 = new Shading(){ Val = ShadingPatternValues.Clear, Color = "auto", Fill = "Blue" };
SpacingBetweenLines spacingBetweenLines1 = new SpacingBetweenLines();
Justification justification1 = new Justification(){ Val = JustificationValues.Left };
NumberingProperties numberingProperties1 = new NumberingProperties();
NumberingLevelReference numberingLevelReference1 = new NumberingLevelReference(){ Val = 0 };
NumberingId numberingId1 = new NumberingId(){ Val = 1 };
numberingProperties1.Append(numberingLevelReference1);
numberingProperties1.Append(numberingId1);
paragraphProperties1.Append(paragraphStyleId1);
paragraphProperties1.Append(shading1);
paragraphProperties1.Append(spacingBetweenLines1);
paragraphProperties1.Append(justification1);
paragraphProperties1.Append(numberingProperties1);
Run run3 = new Run();
Text text2 = new Text();
text2.Text = "AA";
run3.Append(runProperties2);
run3.Append(text2);
paragraph3.Append(paragraphProperties1);
paragraph3.Append(run3);
Paragraph paragraph4 = new Paragraph();
ParagraphProperties paragraphProperties2 = new ParagraphProperties();
ParagraphStyleId paragraphStyleId2 = new ParagraphStyleId(){ Val = "ListParagraph" };
Shading shading2 = new Shading(){ Val = ShadingPatternValues.Clear, Color = "auto", Fill = "Blue" };
SpacingBetweenLines spacingBetweenLines2 = new SpacingBetweenLines();
Justification justification2 = new Justification(){ Val = JustificationValues.Left };
NumberingProperties numberingProperties2 = new NumberingProperties();
NumberingLevelReference numberingLevelReference2 = new NumberingLevelReference(){ Val = 0 };
NumberingId numberingId2 = new NumberingId(){ Val = 2 };
numberingProperties2.Append(numberingLevelReference2);
numberingProperties2.Append(numberingId2);
paragraphProperties2.Append(paragraphStyleId2);
paragraphProperties2.Append(shading2);
paragraphProperties2.Append(spacingBetweenLines2);
paragraphProperties2.Append(justification2);
paragraphProperties2.Append(numberingProperties2);
Run run4 = new Run();
Text text3 = new Text();
text3.Text = "BBB";
run4.Append(runProperties3);
run4.Append(text3);
paragraph4.Append(paragraphProperties2);
paragraph4.Append(run4);
Paragraph paragraph5 = new Paragraph();
ParagraphProperties paragraphProperties3 = new ParagraphProperties();
ParagraphStyleId paragraphStyleId3 = new ParagraphStyleId(){ Val = "ListParagraph" };
Shading shading3 = new Shading(){ Val = ShadingPatternValues.Clear, Color = "auto", Fill = "Blue" };
SpacingBetweenLines spacingBetweenLines3 = new SpacingBetweenLines();
Justification justification3 = new Justification(){ Val = JustificationValues.Left };
NumberingProperties numberingProperties3 = new NumberingProperties();
NumberingLevelReference numberingLevelReference3 = new NumberingLevelReference(){ Val = 0 };
NumberingId numberingId3 = new NumberingId(){ Val = 3 };
numberingProperties3.Append(numberingLevelReference3);
numberingProperties3.Append(numberingId3);
paragraphProperties3.Append(paragraphStyleId3);
paragraphProperties3.Append(shading3);
paragraphProperties3.Append(spacingBetweenLines3);
paragraphProperties3.Append(justification3);
paragraphProperties3.Append(numberingProperties3);
Run run5 = new Run();
Text text4 = new Text();
text4.Text = "CCC";
run5.Append(runProperties4);
run5.Append(text4);
paragraph5.Append(paragraphProperties3);
paragraph5.Append(run5);
body1.Append(paragraph1);
body1.Append(paragraph2);
body1.Append(paragraph3);
body1.Append(paragraph4);
body1.Append(paragraph5);
document1.Append(body1);
document1.Append(openXmlUnknownElement2);
mainDocumentPart1.Document = document1;
Numbering numbering1 = new Numbering();
numbering1.AddNamespaceDeclaration("w", "http://schemas.openxmlformats.org/wordprocessingml/2006/main");
AbstractNum abstractNum1 = new AbstractNum(){ AbstractNumberId = 0 };
MultiLevelType multiLevelType1 = new MultiLevelType(){ Val = MultiLevelValues.HybridMultilevel };
Level level1 = new Level(){ LevelIndex = 0 };
StartNumberingValue startNumberingValue1 = new StartNumberingValue(){ Val = 1 };
NumberingFormat numberingFormat1 = new NumberingFormat(){ Val = NumberFormatValues.Bullet };
LevelText levelText1 = new LevelText(){ Val = "●" };
LevelJustification levelJustification1 = new LevelJustification(){ Val = LevelJustificationValues.Left };
NumberingSymbolRunProperties numberingSymbolRunProperties1 = new NumberingSymbolRunProperties();
RunFonts runFonts6 = new RunFonts(){ Hint = FontTypeHintValues.Default, Ascii = "Arial", HighAnsi = "Arial" };
numberingSymbolRunProperties1.Append(runFonts6);
level1.Append(startNumberingValue1);
level1.Append(numberingFormat1);
level1.Append(levelText1);
level1.Append(levelJustification1);
level1.Append(numberingSymbolRunProperties1);
abstractNum1.Append(multiLevelType1);
abstractNum1.Append(level1);
NumberingInstance numberingInstance1 = new NumberingInstance(){ NumberID = 1 };
AbstractNumId abstractNumId1 = new AbstractNumId(){ Val = 0 };
numberingInstance1.Append(abstractNumId1);
AbstractNum abstractNum2 = new AbstractNum(){ AbstractNumberId = 1 };
MultiLevelType multiLevelType2 = new MultiLevelType(){ Val = MultiLevelValues.HybridMultilevel };
Level level2 = new Level(){ LevelIndex = 0 };
StartNumberingValue startNumberingValue2 = new StartNumberingValue(){ Val = 1 };
NumberingFormat numberingFormat2 = new NumberingFormat(){ Val = NumberFormatValues.Bullet };
LevelText levelText2 = new LevelText(){ Val = "►" };
LevelJustification levelJustification2 = new LevelJustification(){ Val = LevelJustificationValues.Left };
NumberingSymbolRunProperties numberingSymbolRunProperties2 = new NumberingSymbolRunProperties();
RunFonts runFonts7 = new RunFonts(){ Hint = FontTypeHintValues.Default, Ascii = "Arial", HighAnsi = "Arial" };
numberingSymbolRunProperties2.Append(runFonts7);
level2.Append(startNumberingValue2);
level2.Append(numberingFormat2);
level2.Append(levelText2);
level2.Append(levelJustification2);
level2.Append(numberingSymbolRunProperties2);
abstractNum2.Append(multiLevelType2);
abstractNum2.Append(level2);
NumberingInstance numberingInstance2 = new NumberingInstance(){ NumberID = 2 };
AbstractNumId abstractNumId2 = new AbstractNumId(){ Val = 6 };
numberingInstance2.Append(abstractNumId2);
AbstractNum abstractNum3 = new AbstractNum(){ AbstractNumberId = 2 };
MultiLevelType multiLevelType3 = new MultiLevelType(){ Val = MultiLevelValues.HybridMultilevel };
Level level3 = new Level(){ LevelIndex = 0 };
StartNumberingValue startNumberingValue3 = new StartNumberingValue(){ Val = 1 };
NumberingFormat numberingFormat3 = new NumberingFormat(){ Val = NumberFormatValues.Bullet };
LevelText levelText3 = new LevelText(){ Val = "■" };
LevelJustification levelJustification3 = new LevelJustification(){ Val = LevelJustificationValues.Left };
NumberingSymbolRunProperties numberingSymbolRunProperties3 = new NumberingSymbolRunProperties();
RunFonts runFonts8 = new RunFonts(){ Hint = FontTypeHintValues.Default, Ascii = "Arial", HighAnsi = "Arial" };
numberingSymbolRunProperties3.Append(runFonts8);
level3.Append(startNumberingValue3);
level3.Append(numberingFormat3);
level3.Append(levelText3);
level3.Append(levelJustification3);
level3.Append(numberingSymbolRunProperties3);
abstractNum3.Append(multiLevelType3);
abstractNum3.Append(level3);
NumberingInstance numberingInstance3 = new NumberingInstance(){ NumberID = 3 };
AbstractNumId abstractNumId3 = new AbstractNumId(){ Val = 3 };
numberingInstance3.Append(abstractNumId3);
numbering1.Append(abstractNum1);
numbering1.Append(numberingInstance1);
numbering1.Append(abstractNum2);
numbering1.Append(numberingInstance2);
numbering1.Append(abstractNum3);
numbering1.Append(numberingInstance3);
numberingDefinitionsPart1.Numbering = numbering1;
您需要在附加了所有AbstractNumbers之后附加NumberingInstances。他们不应该在他们之间