首页 > 其他 > 详细

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

时间:2017-06-09 09:30:15      阅读:464      评论:0      收藏:0      [点我收藏+]

创建目录

效果图

技术分享

   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操作组件的学习系列二

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!