当前位置: 首页>>代码示例>>C#>>正文


C# DocumentBuilder.StartTable方法代码示例

本文整理汇总了C#中DocumentBuilder.StartTable方法的典型用法代码示例。如果您正苦于以下问题:C# DocumentBuilder.StartTable方法的具体用法?C# DocumentBuilder.StartTable怎么用?C# DocumentBuilder.StartTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DocumentBuilder的用法示例。


在下文中一共展示了DocumentBuilder.StartTable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetTableCellFormatting

        public static void SetTableCellFormatting(string dataDir)
        {
            // ExStart:DocumentBuilderSetTableCellFormatting
            Document doc = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

            builder.StartTable();
            builder.InsertCell();

            // Set the cell formatting
            CellFormat cellFormat = builder.CellFormat;
            cellFormat.Width = 250;
            cellFormat.LeftPadding = 30;
            cellFormat.RightPadding = 30;
            cellFormat.TopPadding = 30;
            cellFormat.BottomPadding = 30;

            builder.Writeln("I'm a wonderful formatted cell.");

            builder.EndRow();
            builder.EndTable();

            dataDir = dataDir + "DocumentBuilderSetTableCellFormatting_out.doc";
            doc.Save(dataDir);
            // ExEnd:DocumentBuilderSetTableCellFormatting
            Console.WriteLine("\nTable cell formatting using DocumentBuilder set successfully.\nFile saved at " + dataDir);
        }
开发者ID:aspose-words,项目名称:Aspose.Words-for-.NET,代码行数:27,代码来源:DocumentBuilderSetFormatting.cs

示例2: Main

        static void Main(string[] args)
        {
            
            Document doc = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

            // We call this method to start building the table.
            builder.StartTable();
            builder.InsertCell();
            builder.Write("Row 1, Cell 1 Content.");

            // Build the second cell
            builder.InsertCell();
            builder.Write("Row 1, Cell 2 Content.");
            // Call the following method to end the row and start a new row.
            builder.EndRow();

            // Build the first cell of the second row.
            builder.InsertCell();
            builder.Write("Row 2, Cell 1 Content");

            // Build the second cell.
            builder.InsertCell();
            builder.Write("Row 2, Cell 2 Content.");
            builder.EndRow();

            // Signal that we have finished building the table.
            builder.EndTable();

            // Save the document to disk.
            doc.Save("DocumentBuilder.CreateSimpleTable Out.doc");
        }
开发者ID:joyang1,项目名称:Aspose_Words_NET,代码行数:32,代码来源:Program.cs

示例3: AutoFitToPageWidth

        /// <summary>
        /// Shows how to set a table to auto fit to 50% of the page width.
        /// </summary>
        private static void AutoFitToPageWidth(string dataDir)
        {
            // ExStart:AutoFitToPageWidth
            Document doc = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

            // Insert a table with a width that takes up half the page width.
            Table table = builder.StartTable();

            // Insert a few cells
            builder.InsertCell();
            table.PreferredWidth = PreferredWidth.FromPercent(50);
            builder.Writeln("Cell #1");

            builder.InsertCell();
            builder.Writeln("Cell #2");

            builder.InsertCell();
            builder.Writeln("Cell #3");

            dataDir = dataDir + "Table.PreferredWidth_out.doc";
           
            // Save the document to disk.
            doc.Save(dataDir);
            // ExEnd:AutoFitToPageWidth
            Console.WriteLine("\nTable autofit successfully to 50% of the page width.\nFile saved at " + dataDir);
        }
开发者ID:aspose-words,项目名称:Aspose.Words-for-.NET,代码行数:30,代码来源:SpecifyHeightAndWidth.cs

示例4: SimpleTable

        private static void SimpleTable(string dataDir)
        {
            // ExStart:SimpleTable
            Document doc = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);
            // We call this method to start building the table.
            builder.StartTable();
            builder.InsertCell();
            builder.Write("Row 1, Cell 1 Content.");
            // Build the second cell
            builder.InsertCell();
            builder.Write("Row 1, Cell 2 Content.");
            // Call the following method to end the row and start a new row.
            builder.EndRow();

            // Build the first cell of the second row.
            builder.InsertCell();
            builder.Write("Row 2, Cell 1 Content");

            // Build the second cell.
            builder.InsertCell();
            builder.Write("Row 2, Cell 2 Content.");
            builder.EndRow();

            // Signal that we have finished building the table.
            builder.EndTable();

            dataDir = dataDir + "DocumentBuilder.CreateSimpleTable_out.doc";
            // Save the document to disk.
            doc.Save(dataDir);
            // ExEnd:SimpleTable
            Console.WriteLine("\nSimple table created successfully.\nFile saved at " + dataDir);
        }
开发者ID:aspose-words,项目名称:Aspose.Words-for-.NET,代码行数:33,代码来源:InsertTableUsingDocumentBuilder.cs

示例5: SetPreferredWidthSettings

        /// <summary>
        /// Shows how to set the different preferred width settings.
        /// </summary>
        private static void SetPreferredWidthSettings(string dataDir)
        {
            // ExStart:SetPreferredWidthSettings
            Document doc = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

            // Insert a table row made up of three cells which have different preferred widths.
            Table table = builder.StartTable();

            // Insert an absolute sized cell.
            builder.InsertCell();
            builder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(40);
            builder.CellFormat.Shading.BackgroundPatternColor = Color.LightYellow;
            builder.Writeln("Cell at 40 points width");

            // Insert a relative (percent) sized cell.
            builder.InsertCell();
            builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);
            builder.CellFormat.Shading.BackgroundPatternColor = Color.LightBlue;
            builder.Writeln("Cell at 20% width");

            // Insert a auto sized cell.
            builder.InsertCell();
            builder.CellFormat.PreferredWidth = PreferredWidth.Auto;
            builder.CellFormat.Shading.BackgroundPatternColor = Color.LightGreen;
            builder.Writeln("Cell automatically sized. The size of this cell is calculated from the table preferred width.");
            builder.Writeln("In this case the cell will fill up the rest of the available space.");

            dataDir = dataDir + "Table.CellPreferredWidths_out.doc";
            // Save the document to disk.
            doc.Save(dataDir);
            // ExEnd:SetPreferredWidthSettings
            Console.WriteLine("\nDifferent preferred width settings set successfully.\nFile saved at " + dataDir);
        }
开发者ID:aspose-words,项目名称:Aspose.Words-for-.NET,代码行数:37,代码来源:SpecifyHeightAndWidth.cs

示例6: Main

        static void Main(string[] args)
        {
            // Check for license and apply if exists
            string licenseFile = AppDomain.CurrentDomain.BaseDirectory + "Aspose.Words.lic";
            if (File.Exists(licenseFile))
            {
                // Apply Aspose.Words API License
                Aspose.Words.License license = new Aspose.Words.License();
                // Place license file in Bin/Debug/ Folder
                license.SetLicense("Aspose.Words.lic");
            }

            Document doc = new Document();

            DocumentBuilder builder = new DocumentBuilder(doc);

            Table table = builder.StartTable();
            builder.InsertCell();

            // Set the borders for the entire table.
            table.SetBorders(LineStyle.Single, 2.0, Color.Black);
            // Set the cell shading for this cell.
            builder.CellFormat.Shading.BackgroundPatternColor = Color.DarkGray;
            builder.Writeln("Cell #1");

            builder.InsertCell();
            // Specify a different cell shading for the second cell.
            builder.CellFormat.Shading.BackgroundPatternColor=Color.Blue;
            builder.Writeln("Cell #2");

            // End this row.
            builder.EndRow();

            // Clear the cell formatting from previous operations.
            builder.CellFormat.ClearFormatting();

            // Create the second row.
            builder.InsertCell();

            // Create larger borders for the first cell of this row. This will be different
            // compared to the borders set for the table.
            builder.CellFormat.Borders.Left.LineWidth=4.0;
            builder.CellFormat.Borders.Right.LineWidth=4.0;
            builder.CellFormat.Borders.Top.LineWidth=4.0;
            builder.CellFormat.Borders.Bottom.LineWidth=4.0;
            builder.Writeln("Cell #3");

            builder.InsertCell();
            // Clear the cell formatting from the previous cell.
            builder.CellFormat.ClearFormatting();
            builder.Writeln("Cell #4");

            doc.Save("Format Table in Document.doc");
        }
开发者ID:aspose-words,项目名称:Aspose.Words-for-.NET,代码行数:54,代码来源:Program.cs

示例7: BuildTableWithStyle

        /// <summary>
        /// Shows how to build a new table with a table style applied.
        /// </summary>
        private static void BuildTableWithStyle(string dataDir)
        {
            // ExStart:BuildTableWithStyle
            Document doc = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

            Table table = builder.StartTable();
            // We must insert at least one row first before setting any table formatting.
            builder.InsertCell();
            // Set the table style used based of the unique style identifier.
            // Note that not all table styles are available when saving as .doc format.
            table.StyleIdentifier = StyleIdentifier.MediumShading1Accent1;
            // Apply which features should be formatted by the style.
            table.StyleOptions = TableStyleOptions.FirstColumn | TableStyleOptions.RowBands | TableStyleOptions.FirstRow;
            table.AutoFit(AutoFitBehavior.AutoFitToContents);

            // Continue with building the table as normal.
            builder.Writeln("Item");
            builder.CellFormat.RightPadding = 40;
            builder.InsertCell();
            builder.Writeln("Quantity (kg)");
            builder.EndRow();

            builder.InsertCell();
            builder.Writeln("Apples");
            builder.InsertCell();
            builder.Writeln("20");
            builder.EndRow();

            builder.InsertCell();
            builder.Writeln("Bananas");
            builder.InsertCell();
            builder.Writeln("40");
            builder.EndRow();

            builder.InsertCell();
            builder.Writeln("Carrots");
            builder.InsertCell();
            builder.Writeln("50");
            builder.EndRow();

            dataDir = dataDir + "DocumentBuilder.SetTableStyle_out.docx";
           
            // Save the document to disk.
            doc.Save(dataDir);
            // ExEnd:BuildTableWithStyle
            Console.WriteLine("\nTable created successfully with table style.\nFile saved at " + dataDir);
        }
开发者ID:aspose-words,项目名称:Aspose.Words-for-.NET,代码行数:51,代码来源:ApplyStyle.cs

示例8: Run

        public static void Run()
        {
            // ExStart:DocumentBuilderBuildTable
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_WorkingWithDocument();
            // Initialize document.
            Document doc = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

            Table table = builder.StartTable();

            // Insert a cell
            builder.InsertCell();
            // Use fixed column widths.
            table.AutoFit(AutoFitBehavior.FixedColumnWidths);

            builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
            builder.Write("This is row 1 cell 1");

            // Insert a cell
            builder.InsertCell();
            builder.Write("This is row 1 cell 2");

            builder.EndRow();

            // Insert a cell
            builder.InsertCell();

            // Apply new row formatting
            builder.RowFormat.Height = 100;
            builder.RowFormat.HeightRule = HeightRule.Exactly;

            builder.CellFormat.Orientation = TextOrientation.Upward;
            builder.Writeln("This is row 2 cell 1");

            // Insert a cell
            builder.InsertCell();
            builder.CellFormat.Orientation = TextOrientation.Downward;
            builder.Writeln("This is row 2 cell 2");

            builder.EndRow();

            builder.EndTable();
            dataDir = dataDir + "DocumentBuilderBuildTable_out.doc";
            doc.Save(dataDir);
            // ExEnd:DocumentBuilderBuildTable
            Console.WriteLine("\nTable build successfully using DocumentBuilder.\nFile saved at " + dataDir);
        }     
开发者ID:aspose-words,项目名称:Aspose.Words-for-.NET,代码行数:48,代码来源:DocumentBuilderBuildTable.cs

示例9: Main

        static void Main(string[] args)
        {
            // Check for license and apply if exists
            string licenseFile = AppDomain.CurrentDomain.BaseDirectory + "Aspose.Words.lic";
            if (File.Exists(licenseFile))
            {
                // Apply Aspose.Words API License
                Aspose.Words.License license = new Aspose.Words.License();
                // Place license file in Bin/Debug/ Folder
                license.SetLicense("Aspose.Words.lic");
            }

            Document doc = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

            // Start building a the table.
            builder.StartTable();
            builder.InsertCell();
            builder.Write("Row 1, Cell 1 Content");

            // Build the second cell
            builder.InsertCell();
            builder.Write("Row 1, Cell 2 Content");

            // End previous row and start new
            builder.EndRow();

            // Build the first cell of 2nd row
            builder.InsertCell();
            builder.Write("Row 2, Cell 1 Content");

            builder.InsertCell();
            builder.Write("Row 2, Cell 2 Content");

            builder.EndRow();

            // End the table
            builder.EndTable();

            Range range = doc.Sections[0].Range;
            range.Delete();

            String text = doc.Range.Text;

            System.Console.WriteLine(text);
            System.Console.ReadKey();
        }
开发者ID:aspose-words,项目名称:Aspose.Words-for-.NET,代码行数:47,代码来源:Program.cs

示例10: Run

        public static void Run()
        {
            // ExStart:BookmarkTable
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_WorkingWithBookmarks();
            
            // Create empty document
            Document doc = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

            Table table = builder.StartTable();

            // Insert a cell
            builder.InsertCell();

            // Start bookmark here after calling InsertCell
            builder.StartBookmark("MyBookmark");

            builder.Write("This is row 1 cell 1");

            // Insert a cell
            builder.InsertCell();
            builder.Write("This is row 1 cell 2");

            builder.EndRow();

            // Insert a cell
            builder.InsertCell();
            builder.Writeln("This is row 2 cell 1");

            // Insert a cell
            builder.InsertCell();
            builder.Writeln("This is row 2 cell 2");

            builder.EndRow();

            builder.EndTable();
            // End of bookmark
            builder.EndBookmark("MyBookmark");

            dataDir = dataDir + "Bookmark.Table_out.doc";
            doc.Save(dataDir);
            // ExEnd:BookmarkTable
            Console.WriteLine("\nTable bookmarked successfully.\nFile saved at " + dataDir);
        }
开发者ID:aspose-words,项目名称:Aspose.Words-for-.NET,代码行数:45,代码来源:BookmarkTable.cs

示例11: Main

        static void Main(string[] args)
        {
            Document doc = new Document();

            DocumentBuilder builder = new DocumentBuilder(doc);

            Table table = builder.StartTable();
            builder.InsertCell();

            // Set the borders for the entire table.
            table.SetBorders(LineStyle.Single, 2.0, Color.Black);
            // Set the cell shading for this cell.
            builder.CellFormat.Shading.BackgroundPatternColor = Color.DarkGray;
            builder.Writeln("Cell #1");

            builder.InsertCell();
            // Specify a different cell shading for the second cell.
            builder.CellFormat.Shading.BackgroundPatternColor=Color.Blue;
            builder.Writeln("Cell #2");

            // End this row.
            builder.EndRow();

            // Clear the cell formatting from previous operations.
            builder.CellFormat.ClearFormatting();

            // Create the second row.
            builder.InsertCell();

            // Create larger borders for the first cell of this row. This will be different
            // compared to the borders set for the table.
            builder.CellFormat.Borders.Left.LineWidth=4.0;
            builder.CellFormat.Borders.Right.LineWidth=4.0;
            builder.CellFormat.Borders.Top.LineWidth=4.0;
            builder.CellFormat.Borders.Bottom.LineWidth=4.0;
            builder.Writeln("Cell #3");

            builder.InsertCell();
            // Clear the cell formatting from the previous cell.
            builder.CellFormat.ClearFormatting();
            builder.Writeln("Cell #4");

            doc.Save("data/Format Table in Document.doc");
        }
开发者ID:joyang1,项目名称:Aspose_Words_NET,代码行数:44,代码来源:Program.cs

示例12: Run

        public static void Run()
        {
            // ExStart:RepeatRowsOnSubsequentPages
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_WorkingWithTables();

            Document doc = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

            Table table = builder.StartTable();
            builder.RowFormat.HeadingFormat = true;
            builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
            builder.CellFormat.Width = 100;
            builder.InsertCell();
            builder.Writeln("Heading row 1");
            builder.EndRow();
            builder.InsertCell();
            builder.Writeln("Heading row 2");
            builder.EndRow();

            builder.CellFormat.Width = 50;
            builder.ParagraphFormat.ClearFormatting();

            // Insert some content so the table is long enough to continue onto the next page.
            for (int i = 0; i < 50; i++)
            {
                builder.InsertCell();
                builder.RowFormat.HeadingFormat = false;
                builder.Write("Column 1 Text");
                builder.InsertCell();
                builder.Write("Column 2 Text");
                builder.EndRow();
            }

            dataDir = dataDir + "Table.HeadingRow_out.doc";
            // Save the document to disk.
            doc.Save(dataDir);
            // ExEnd:RepeatRowsOnSubsequentPages
            Console.WriteLine("\nTable build successfully which include heading rows that repeat on subsequent pages..\nFile saved at " + dataDir);
        }
开发者ID:aspose-words,项目名称:Aspose.Words-for-.NET,代码行数:40,代码来源:RepeatRowsOnSubsequentPages.cs

示例13: Primer

        //ExStart
        //ExId:HeaderFooterPrimer
        //ExSummary:Maybe a bit complicated example, but demonstrates many things that can be done with headers/footers.
        public void Primer()
        {
            Aspose.Words.Document doc = new Aspose.Words.Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

            Aspose.Words.Section currentSection = builder.CurrentSection;
            Aspose.Words.PageSetup pageSetup = currentSection.PageSetup;

            // Specify if we want headers/footers of the first page to be different from other pages.
            // You can also use PageSetup.OddAndEvenPagesHeaderFooter property to specify
            // different headers/footers for odd and even pages.
            pageSetup.DifferentFirstPageHeaderFooter = true;

            // --- Create header for the first page. ---
            pageSetup.HeaderDistance = 20;
            builder.MoveToHeaderFooter(HeaderFooterType.HeaderFirst);
            builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;

            // Set font properties for header text.
            builder.Font.Name = "Arial";
            builder.Font.Bold = true;
            builder.Font.Size = 14;
            // Specify header title for the first page.
            builder.Write("Aspose.Words Header/Footer Creation Primer - Title Page.");

            // --- Create header for pages other than first. ---
            pageSetup.HeaderDistance = 20;
            builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);

            // Insert absolutely positioned image into the top/left corner of the header.
            // Distance from the top/left edges of the page is set to 10 points.
            string imageFileName = ExDir + "Aspose.Words.gif";
            builder.InsertImage(imageFileName, RelativeHorizontalPosition.Page, 10, RelativeVerticalPosition.Page, 10, 50, 50, WrapType.Through);

            builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;
            // Specify another header title for other pages.
            builder.Write("Aspose.Words Header/Footer Creation Primer.");

            // --- Create footer for pages other than first. ---
            builder.MoveToHeaderFooter(HeaderFooterType.FooterPrimary);

            // We use table with two cells to make one part of the text on the line (with page numbering)
            // to be aligned left, and the other part of the text (with copyright) to be aligned right.
            builder.StartTable();

            // Clear table borders.
            builder.CellFormat.ClearFormatting();

            builder.InsertCell();

            // Set first cell to 1/3 of the page width.
            builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(100 / 3);

            // Insert page numbering text here.
            // It uses PAGE and NUMPAGES fields to auto calculate current page number and total number of pages.
            builder.Write("Page ");
            builder.InsertField("PAGE", "");
            builder.Write(" of ");
            builder.InsertField("NUMPAGES", "");

            // Align this text to the left.
            builder.CurrentParagraph.ParagraphFormat.Alignment = ParagraphAlignment.Left;

            builder.InsertCell();
            // Set the second cell to 2/3 of the page width.
            builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(100 * 2 / 3);

            builder.Write("(C) 2001 Aspose Pty Ltd. All rights reserved.");

            // Align this text to the right.
            builder.CurrentParagraph.ParagraphFormat.Alignment = ParagraphAlignment.Right;

            builder.EndRow();
            builder.EndTable();

            builder.MoveToDocumentEnd();
            // Make page break to create a second page on which the primary headers/footers will be seen.
            builder.InsertBreak(BreakType.PageBreak);

            // Make section break to create a third page with different page orientation.
            builder.InsertBreak(BreakType.SectionBreakNewPage);

            // Get the new section and its page setup.
            currentSection = builder.CurrentSection;
            pageSetup = currentSection.PageSetup;

            // Set page orientation of the new section to landscape.
            pageSetup.Orientation = Orientation.Landscape;

            // This section does not need different first page header/footer.
            // We need only one title page in the document and the header/footer for this page
            // has already been defined in the previous section
            pageSetup.DifferentFirstPageHeaderFooter = false;

            // This section displays headers/footers from the previous section by default.
            // Call currentSection.HeadersFooters.LinkToPrevious(false) to cancel this.
            // Page width is different for the new section and therefore we need to set
//.........这里部分代码省略.........
开发者ID:joyang1,项目名称:Aspose_Words_NET,代码行数:101,代码来源:ExHeaderFooter.cs

示例14: Main

        static void Main(string[] args)
        {
            //----------------------------------------------------
            //  NPOI
            //----------------------------------------------------            
            //XWPFDocument doc = new XWPFDocument();
            //XWPFParagraph para = doc.CreateParagraph();
            //XWPFRun r0 = para.CreateRun();
            //r0.SetText("Title1");
            //para.BorderTop = Borders.THICK;
            //para.FillBackgroundColor = "EEEEEE";
            //para.FillPattern = NPOI.OpenXmlFormats.Wordprocessing.ST_Shd.diagStripe;

            //XWPFTable table = doc.CreateTable(3, 3);

            //table.GetRow(1).GetCell(1).SetText("EXAMPLE OF TABLE");

            //XWPFTableCell c1 = table.GetRow(0).GetCell(0);
            //XWPFParagraph p1 = c1.AddParagraph();   //don't use doc.CreateParagraph
            //XWPFRun r1 = p1.CreateRun();
            //r1.SetText("The quick brown fox");
            //r1.SetBold(true);

            //r1.FontFamily = "Courier";
            //r1.SetUnderline(UnderlinePatterns.DotDotDash);
            //r1.SetTextPosition(100);
            //c1.SetColor("FF0000");


            //table.GetRow(2).GetCell(2).SetText("only text");

            //FileStream out1 = new FileStream("simpleTable.docx", FileMode.Create);
            //doc.Write(out1);
            //out1.Close();


            //----------------------------------------------------
            //  Aspose.Words
            //----------------------------------------------------

            // Check for license and apply if exists
            string licenseFile = AppDomain.CurrentDomain.BaseDirectory + "Aspose.Words.lic";
            if (File.Exists(licenseFile))
            {
                // Apply Aspose.Words API License
                Aspose.Words.License license = new Aspose.Words.License();
                // Place license file in Bin/Debug/ Folder
                license.SetLicense("Aspose.Words.lic");
            }


            Document doc = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

            builder.ParagraphFormat.Borders.Top.LineStyle = LineStyle.Thick;
            builder.ParagraphFormat.Shading.BackgroundPatternColor = System.Drawing.ColorTranslator.FromHtml("#EEEEEE");
            builder.ParagraphFormat.Shading.Texture = TextureIndex.TextureDarkDiagonalUp;
            builder.Writeln("Title1");
            
            builder.ParagraphFormat.ClearFormatting();            
            builder.InsertBreak(BreakType.ParagraphBreak);

            // We call this method to start building the table.
            builder.StartTable();
            builder.InsertCell();

            builder.CellFormat.Shading.BackgroundPatternColor = System.Drawing.ColorTranslator.FromHtml("#FF0000");
            builder.Font.Position = 100;
            builder.Font.Name = "Courier";
            builder.Font.Bold = true;
            builder.Font.Underline = Underline.DotDotDash;
            builder.Write("The quick brown fox");
            builder.InsertCell();

            builder.Font.ClearFormatting();
            builder.CellFormat.ClearFormatting();

            builder.InsertCell();
            builder.EndRow();

            builder.InsertCell();
            builder.InsertCell();
            builder.Write("EXAMPLE OF TABLE");
            builder.InsertCell(); 
            builder.EndRow();

            builder.InsertCell();
            builder.InsertCell();
            builder.InsertCell();
            builder.Write("only text");
            builder.EndRow();

            // Signal that we have finished building the table.
            builder.EndTable();

            doc.Save("simpleTable.docx");

        }
开发者ID:aspose-words,项目名称:Aspose.Words-for-.NET,代码行数:98,代码来源:Program.cs

示例15: Execute

        protected override void Execute(CodeActivityContext executionContext)
        {
            // Get Values from the Input Parameters
            bool Logging = EnableLogging.Get(executionContext);
            string LicenseFilePath = LicenseFile.Get(executionContext);
            string LogFilePath = LogFile.Get(executionContext);
            int detectIn = DetectIn.Get(executionContext);
            OutputAttachmentId.Set(executionContext, new EntityReference("annotation", Guid.Empty));

            if (Logging)
                Log("Execution Started", LogFilePath);

            // Creating CRM service from Context
            IWorkflowContext context = executionContext.GetExtension<IWorkflowContext>();
            IOrganizationServiceFactory serviceFactory = executionContext.GetExtension<IOrganizationServiceFactory>();
            IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);

            try
            {
                // Applying Licence for Aspose (If Exist)
                if (Logging)
                    Log("Enable Licensing", LogFilePath);
                if (LicenseFilePath != "" && File.Exists(LicenseFilePath))
                {
                    License Lic = new License();
                    Lic.SetLicense(LicenseFilePath);
                    if (Logging)
                        Log("License Set", LogFilePath);
                }
            }
            catch (Exception ex)
            {
                Log("Error while applying license: " + ex.Message, LogFilePath);
            }

            if (detectIn == 0) // under this record
            {
                Guid ThisRecordId = context.PrimaryEntityId;
                string RecordType = context.PrimaryEntityName;
                Document Result = new Document();
                DocumentBuilder ResultWriter = new DocumentBuilder(Result);
                if (Logging)
                    Log("Working under all attachments under this record", LogFilePath);
                // Retrieve All attachments under this Record
                QueryExpression RetrieveNoteQuery = new QueryExpression("annotation");
                RetrieveNoteQuery.ColumnSet = new ColumnSet(new string[] { "filename", "subject", "documentbody" });
                RetrieveNoteQuery.Criteria.AddCondition(new ConditionExpression("objectid", ConditionOperator.Equal, ThisRecordId));
                if (Logging)
                    Log("Executing Query to retrieve All Notes within this record", LogFilePath);
                EntityCollection Notes = service.RetrieveMultiple(RetrieveNoteQuery);
                // Loop through All Notes
                foreach (Entity Note in Notes.Entities)
                {
                    try
                    {
                        if (Note.Contains("documentbody"))
                        {
                            string FileName = "";
                            if (Note.Contains("filename"))
                                FileName = Note["filename"].ToString();

                            // Read Attachment in Aspose
                            byte[] DocumentBody = Convert.FromBase64String(Note["documentbody"].ToString());
                            MemoryStream fileStream = new MemoryStream(DocumentBody);
                            Document doc = new Document(fileStream);

                            ResultWriter.Writeln("Comparing Document: " + FileName);
                            ResultWriter.StartTable();

                            // Comparing document with other attachments
                            foreach (Entity OtherNote in Notes.Entities)
                            {
                                if (OtherNote.Id != Note.Id)
                                {
                                    if (OtherNote.Contains("documentbody"))
                                    {
                                        string OtherFileName = "";
                                        if (OtherNote.Contains("filename"))
                                            OtherFileName = OtherNote["filename"].ToString();
                                        // Reading attachment in Aspose
                                        byte[] OtherDocumentBody = Convert.FromBase64String(OtherNote["documentbody"].ToString());
                                        MemoryStream fileStream2 = new MemoryStream(OtherDocumentBody);
                                        Document doc2 = new Document(fileStream);

                                        ResultWriter.InsertCell();
                                        ResultWriter.Write(OtherFileName);

                                        // Compare documents
                                        doc.Compare(doc2, "a", DateTime.Now);
                                        if (doc.Revisions.Count == 0)
                                        {
                                            // If documents are same
                                            ResultWriter.InsertCell();
                                            ResultWriter.Write("Duplicate Documents");
                                        }
                                        ResultWriter.EndRow();
                                    }
                                }
                            }
                            ResultWriter.EndTable();
//.........这里部分代码省略.........
开发者ID:joyang1,项目名称:Aspose_Words_NET,代码行数:101,代码来源:DuplicateDocument.cs


注:本文中的DocumentBuilder.StartTable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。