コード例 #1
0
ファイル: TableOfContentSample.cs プロジェクト: ysking/DocX
        /// <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 (var 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 add all teams right after.
                var p = document.InsertParagraph();
                TableOfContentSample.AddTeams(p);

                // Insert a table of content just before the paragraph p.
                var tocSwitches = new Dictionary <TableOfContentsSwitches, string>()
                {
                    { TableOfContentsSwitches.O, "1-3" },
                    { TableOfContentsSwitches.U, "" },
                    { TableOfContentsSwitches.Z, "" },
                    { TableOfContentsSwitches.H, "" }
                };
                document.InsertTableOfContents(p, "Teams", tocSwitches, "Heading4");

                document.Save();
                Console.WriteLine("\tCreated: InsertTableOfContentWithReference.docx\n");
            }
        }
コード例 #2
0
ファイル: TableOfContentSample.cs プロジェクト: ysking/DocX
        /// <summary>
        /// Add a Table of content to a document.
        /// </summary>
        public static void InsertTableOfContent()
        {
            Console.WriteLine("\tInsertTableOfContent()");

            // Creates a document
            using (var 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 and a page break.
                var tocSwitches = new Dictionary <TableOfContentsSwitches, string>()
                {
                    { TableOfContentsSwitches.O, "1-3" },
                    { TableOfContentsSwitches.U, "" },
                    { TableOfContentsSwitches.Z, "" },
                    { TableOfContentsSwitches.H, "" },
                };
                document.InsertTableOfContents("Teams", tocSwitches);
                document.InsertParagraph().InsertPageBreakAfterSelf();

                // Create a paragraph and add teams.
                var p = document.InsertParagraph();
                TableOfContentSample.AddTeams(p);

                document.Save();
                Console.WriteLine("\tCreated: InsertTableOfContent.docx\n");
            }
        }
コード例 #3
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 (var 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");
            }
        }
コード例 #4
0
        /// <summary>
        /// Add a Table of content to a document.
        /// </summary>
        public static void InsertTableOfContent()
        {
            Console.WriteLine("\tInsertTableOfContent()");

            // Creates a document
            using (var 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");
            }
        }
コード例 #5
0
        private 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.AddAppProperties();
            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();
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: ysking/DocX
        private static void Main(string[] args)
        {
            var version       = Assembly.GetExecutingAssembly().GetName().Version;
            var versionNumber = version.Major + "." + version.Minor;

            Console.WriteLine("\nRunning Examples of Xceed Words for .NET version " + versionNumber + ".\n");

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

            //Document
            DocumentSample.AddCustomProperties();
            DocumentSample.ReplaceTextWithText();
            DocumentSample.ReplaceTextWithObjects();
            DocumentSample.ApplyTemplate();
            DocumentSample.AppendDocument();
            DocumentSample.LoadDocumentWithFilename();
            DocumentSample.LoadDocumentWithStream();
            DocumentSample.LoadDocumentWithStringUrl();
            DocumentSample.AddHtmlFromFile();
            DocumentSample.AddRtfFromFile();

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

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

            //Header/Footers
            HeaderFooterSample.HeadersFooters();

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

            //Hyperlink
            HyperlinkSample.Hyperlinks();

            //Section
            SectionSample.InsertSections();
            SectionSample.SetPageOrientations();

            //Lists
            ListSample.AddList();
            ListSample.CloneLists();

            //Equations
            EquationSample.InsertEquation();

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

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

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

            //Lines
            LineSample.InsertHorizontalLine();

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

            //Parallel
            ParallelSample.DoParallelActions();

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

            //PDF
            PdfSample.ConvertToPDF();

            //Shape
            ShapeSample.AddShape();
            ShapeSample.AddShapeWithTextWrapping();
            ShapeSample.AddTextBox();
            ShapeSample.AddTextBoxWithTextWrapping();

            //CheckBox
            CheckBoxSample.ModifyCheckBox();
            CheckBoxSample.AddCheckBox();

            Console.WriteLine("\nDone running Examples of Xceed Words for .NET version " + versionNumber + ".\n");
            Console.WriteLine("\nPress any key to exit.");
            Console.ReadKey();
        }