示例#1
0
        public void TestUpdateFields()
        {
            XWPFDocument doc = new XWPFDocument();

            Assert.IsFalse(doc.IsEnforcedUpdateFields());
            doc.EnforceUpdateFields();
            Assert.IsTrue(doc.IsEnforcedUpdateFields());
        }
        /// <summary>
        /// Renders a Table of Contents (TOC) in front of the document.
        ///
        /// Please set the paragraphs style to "Heading{#}".
        /// Otherwise, it renders an empty TOC.
        /// </summary>
        private void RenderTOC()
        {
            TOC         tocBuilder      = new TOC();
            CT_SdtBlock tableOfContents = tocBuilder.Build();
            CT_P        pHeader         = CreateFrontHeader();

            newDoc.Document.body.Items.Add(tableOfContents);
            newDoc.Document.body.Items.Add(pHeader);
            newDoc.CreateParagraph().CreateRun().AddBreak(BreakType.PAGE);

            newDoc.EnforceUpdateFields();
        }