C#DocX:插入新的编号列表将继续编号 [英] C# DocX: Inserting new numbered list continues numbering
问题描述
我正在尝试使用Novacode DocX在Word文档中插入几个编号列表.
I am trying to insert several numbered lists into a Word document using Novacode DocX.
类似这样的东西:
var doc = DocX.Create("somedoc.docx");
var list = doc.AddList(listType: ListItemType.Numbered, startNumber: 1);
doc.AddListItem(list, "Number 1", 0, listType);
doc.AddListItem(list, "Number 2", 0, listType);
doc.InsertList(list);
doc.InsertParagraph(); //just to get some space between.
var secondList= doc.AddList(listType: ListItemType.Numbered, startNumber: 1);
doc.AddListItem(secondList, "Number 1", 0, listType);
doc.AddListItem(secondList, "Number 2", 0, listType);
doc.InsertList(secondList);
这将产生此结果:
- 第1名
- 第2名
- 第1名
- 第2名
我期望的是:
- 第1名
- 第2名
- 第1名
- 第2名
似乎startNumber参数不起作用.在生成的文档的numbering.xml文件中,我可以看到numIds和abstractNumIds似乎都是正确生成的.这两个列表具有不同的numId,每个numId都引用了不同的abstractNumId.
It seems that the startNumber parameter does not work. In the resulting document's numbering.xml file, I can see that both numIds and abstractNumIds seem to be generated correctly. The two list have different numIds, each referring to different abstractNumIds.
任何人都知道可能是什么问题(除了DocX库中的错误)?我将在Word 2010中打开文档,因此我有一个理论是DocX和Word> 2007之间存在某些不兼容.如果是这种情况,则在生成文档后,我可能不得不对XML进行一些操作. >
Anyone got any idea about what might be the problem (other than a bug in the DocX library)? I am opening the document in Word 2010, so one theory I have is that there is some incompatability with DocX and Word > 2007. If that is the case, I probably have to do something with the XML after generating the document..
推荐答案
原来是Novacode.Docx中的错误.我为此提交了一个补丁,该补丁已在1.0.0.16版本中应用
Turned out to be a bug in Novacode.Docx. I submitted a patch for it that was applied in version 1.0.0.16
这篇关于C#DocX:插入新的编号列表将继续编号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!