コード例 #1
0
        /// <summary>
        /// Add a Table of content to a document by inserting it just before a reference paragraph.
        /// </summary>
        public static void InsertTableOfContentWithReference()
        {
            Console.WriteLine("\tInsertTableOfContentWithReference()");

            // Create a document.
            using (DocX document = DocX.Create(TableOfContentSample.TableOfContentSampleOutputDirectory + @"InsertTableOfContentWithReference.docx"))
            {
                // Add a title.
                document.InsertParagraph("Insert Table of content with reference").FontSize(15d).SpacingAfter(50d).Alignment = Alignment.center;

                // Add an intro paragraph.
                var intro = document.InsertParagraph("This page will show the team rosters of the American League East Division.");
                intro.SpacingAfter(150d);

                // Create a paragraph and fill it in method AddTeams().
                var p       = document.InsertParagraph();
                var rosters = TableOfContentSample.AddTeams(p);
                document.InsertParagraph(rosters);

                // Insert a table of content with a page break just before the paragraph p.
                document.InsertTableOfContents(p,
                                               "Teams",
                                               TableOfContentsSwitches.O | TableOfContentsSwitches.U | TableOfContentsSwitches.Z | TableOfContentsSwitches.H,
                                               "Heading4");

                document.Save();
                Console.WriteLine("\tCreated: InsertTableOfContentWithReference.docx\n");
            }
        }
コード例 #2
0
        /// <summary>
        /// Add a Table of content to a document.
        /// </summary>
        public static void InsertTableOfContent()
        {
            Console.WriteLine("\tInsertTableOfContent()");

            // Creates a document
            using (DocX document = DocX.Create(TableOfContentSample.TableOfContentSampleOutputDirectory + @"InsertTableOfContent.docx"))
            {
                // Add a title
                document.InsertParagraph("Insert Table of content").FontSize(15d).SpacingAfter(50d).Alignment = Alignment.center;

                // Insert a table of content with a page break.
                document.InsertTableOfContents("Teams", TableOfContentsSwitches.O | TableOfContentsSwitches.U | TableOfContentsSwitches.Z | TableOfContentsSwitches.H);
                document.InsertSectionPageBreak();

                // Create a paragraph and fill it in method AddTeams().
                var p       = document.InsertParagraph();
                var rosters = TableOfContentSample.AddTeams(p);
                document.InsertParagraph(rosters);

                document.Save();
                Console.WriteLine("\tCreated: InsertTableOfContent.docx\n");
            }
        }
コード例 #3
0
        static void Main(string[] args)
        {
            Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");

            //Paragraphs
            ParagraphSample.SimpleFormattedParagraphs();
            ParagraphSample.ForceParagraphOnSinglePage();
            ParagraphSample.ForceMultiParagraphsOnSinglePage();
            ParagraphSample.TextActions();
            ParagraphSample.Heading();

            //Document
            DocumentSample.AddCustomProperties();
            DocumentSample.ReplaceText();
            DocumentSample.ApplyTemplate();
            DocumentSample.AppendDocument();

            //Images
            ImageSample.AddPicture();
            ImageSample.CopyPicture();

            ImageSample.ModifyImage();

            //Indentation/Direction/Margins
            MarginSample.SetDirection();
            MarginSample.Indentation();
            MarginSample.Margins();

            //Header/Footers
            HeaderFooterSample.HeadersFooters();

            //Tables
            TableSample.InsertRowAndImageTable();
            TableSample.TextDirectionTable();
            TableSample.CreateRowsFromTemplate();
            TableSample.ColumnsWidth();
            TableSample.MergeCells();

            //Hyperlink
            HyperlinkSample.Hyperlinks();

            //Section
            SectionSample.InsertSections();

            //Lists
            ListSample.AddList();

            //Equations
            EquationSample.InsertEquation();

            //Bookmarks
            BookmarkSample.InsertBookmarks();
            BookmarkSample.ReplaceText();

            //Charts
            ChartSample.BarChart();
            ChartSample.LineChart();
            ChartSample.PieChart();
            ChartSample.Chart3D();

            //Tale of Content
            TableOfContentSample.InsertTableOfContent();
            TableOfContentSample.InsertTableOfContentWithReference();

            //Lines
            LineSample.InsertHorizontalLine();

            //Protection
            ProtectionSample.AddPasswordProtection();
            ProtectionSample.AddProtection();

            //Parallel
            ParallelSample.DoParallelActions();

            //Others
            MiscellaneousSample.CreateRecipe();
            MiscellaneousSample.CompanyReport();
            MiscellaneousSample.CreateInvoice();

            Console.WriteLine("\nPress any key to exit.");
            Console.ReadKey();

            Console.ReadLine();
        }