How to generate Table Of Contents using OpenXML SDK 2.0?

后端 未结 4 686
夕颜
夕颜 2020-12-16 18:39

Using the SDK I\'m building Word documents that contain reports. These documents need to have TOC. Does anybody have a complete solution that I can follow in order to unders

4条回答
  •  我在风中等你
    2020-12-16 18:54

    If you have a TOC field, this will cause it to be updated when the document is opened in Word (body is a reference to the document body):

    DocumentFormat.OpenXml.Wordprocessing.SimpleField f;
    f = new SimpleField();
    f.Instruction="sdtContent";
    f.Dirty = true;
    body.Append(f);
    

提交回复
热议问题