Aspose.Slides.Examples.CSharp.Tables.VerticallyAlignText.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();

            // Create an instance of Presentation class
            Presentation presentation = new Presentation();

            // Get the first slide 
            ISlide slide = presentation.Slides[0];

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

            // Add table shape to slide
            ITable tbl = slide.Shapes.AddTable(100, 50, dblCols, dblRows);
            tbl[1, 0].TextFrame.Text = "10";
            tbl[2, 0].TextFrame.Text = "20";
            tbl[3, 0].TextFrame.Text = "30";

            // Accessing the text frame
            ITextFrame txtFrame = tbl[0, 0].TextFrame;

            // Create the Paragraph object for text frame
            IParagraph paragraph = txtFrame.Paragraphs[0];

            // Create Portion object for paragraph
            IPortion portion = paragraph.Portions[0];
            portion.Text = "Text here";
            portion.PortionFormat.FillFormat.FillType = FillType.Solid;
            portion.PortionFormat.FillFormat.SolidFillColor.Color = Color.Black;

            // Aligning the text vertically
            ICell cell = tbl[0, 0];
            cell.TextAnchorType = TextAnchorType.Center;
            cell.TextVerticalType = TextVerticalType.Vertical270;

            // Save Presentation
            presentation.Save(dataDir +  "Vertical_Align_Text_out.pptx", SaveFormat.Pptx);

         }
    }
VerticallyAlignText