码迷,mamicode.com
首页 > 其他好文 > 详细

DocX开源WORD操作组件的学习系列二

时间:2017-06-09 10:06:17      阅读:269      评论:0      收藏:0      [点我收藏+]

标签:span   add   docx   contents   res   com   save   rtp   创建目录   

创建目录

效果图

技术分享

   static void AddToc()
        {
            Console.WriteLine("\tAddToc()");

            using (var document = DocX.Create(@"docs\Toc2.docx"))
            {
              
                document.InsertTableOfContents("1 目录", TableOfContentsSwitches.O | TableOfContentsSwitches.U | TableOfContentsSwitches.Z | TableOfContentsSwitches.H, "Heading1");
               // document.InsertSectionPageBreak();//分页
                var h1 = document.InsertParagraph("2 测试1");
                h1.StyleName = "Heading1";
                document.InsertParagraph("Some very interesting content here");
                var h2 = document.InsertParagraph("3 测试2");
                h2.StyleName = "Heading1";
                document.InsertParagraph("Some very interesting content here as well");
                var h3 = document.InsertParagraph("3.1 测试3.1");
                h3.StyleName = "Heading2";
                var h4 = document.InsertParagraph("3.1.1 测试3.1.1");
                h4.StyleName = "Heading3";
                var h5 = document.InsertParagraph("4 测试4");
                h5.StyleName = "Heading1";
                document.InsertParagraph("Not so very interesting....");
                document.Save();
            }
        }

 

DocX开源WORD操作组件的学习系列二

标签:span   add   docx   contents   res   com   save   rtp   创建目录   

原文地址:http://www.cnblogs.com/zhaojiedi1992/p/zhaojiedi_csharp_005_docx2.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!