Aspose.Slides.Examples.CSharp.Tables.CellSplit.Run C# (CSharp) Method

Run() public static method

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

            // Instantiate Presentation class that represents PPTX file
            using (Presentation presentation = new Presentation())
            {
                // Access first slide
                ISlide slide = presentation.Slides[0];

                // Define columns with widths and rows with heights
                double[] dblCols = { 70, 70, 70, 70 };
                double[] dblRows = { 70, 70, 70, 70 };

                // Add table shape to slide
                ITable table = slide.Shapes.AddTable(100, 50, dblCols, dblRows);

                // Set border format for each cell
                foreach (IRow row in table.Rows)
                {
                    foreach (ICell cell in row)
                    {
                        cell.BorderTop.FillFormat.FillType = FillType.Solid;
                        cell.BorderTop.FillFormat.SolidFillColor.Color = Color.Red;
                        cell.BorderTop.Width = 5;


                        cell.BorderBottom.FillFormat.FillType = FillType.Solid;
                        cell.BorderBottom.FillFormat.SolidFillColor.Color = Color.Red;
                        cell.BorderBottom.Width = 5;

                        cell.BorderLeft.FillFormat.FillType = FillType.Solid;
                        cell.BorderLeft.FillFormat.SolidFillColor.Color = Color.Red;
                        cell.BorderLeft.Width = 5;

                        cell.BorderRight.FillFormat.FillType = FillType.Solid;
                        cell.BorderRight.FillFormat.SolidFillColor.Color = Color.Red;
                        cell.BorderRight.Width = 5;
                        
                    }
                }

                // Merging cells (1, 1) x (2, 1)
                table.MergeCells(table[1, 1], table[2, 1], false);

                // Merging cells (1, 2) x (2, 2)
                table.MergeCells(table[1, 2], table[2, 2], false);

                // split cell (1, 1). 
                table[1, 1].SplitByWidth(table[2, 1].Width / 2);

                //Write PPTX to Disk
                presentation.Save(dataDir + "CellSplit_out.pptx", SaveFormat.Pptx);

            }
         }
    }
CellSplit