Пример #1
0
        public static void Run()
        {
            //ExStart:SetTextFormattingInsideTable
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Tables();
            // Create an instance of Presentation class
            Presentation presentation = new Presentation(dataDir + "pres.pptx");
            ISlide       slide        = presentation.Slides[0];

            ITable someTable = presentation.Slides[0].Shapes[0] as ITable; // let's say that the first shape on the first slide is a table

            // setting table cells' font height
            PortionFormat portionFormat = new PortionFormat();

            portionFormat.FontHeight = 25;
            someTable.SetTextFormat(portionFormat);

            // setting table cells' text alignment and right margin in one call
            ParagraphFormat paragraphFormat = new ParagraphFormat();

            paragraphFormat.Alignment   = TextAlignment.Right;
            paragraphFormat.MarginRight = 20;
            someTable.SetTextFormat(paragraphFormat);

            // setting table cells' text vertical type
            TextFrameFormat textFrameFormat = new TextFrameFormat();

            textFrameFormat.TextVerticalType = TextVerticalType.Vertical;
            someTable.SetTextFormat(textFrameFormat);


            presentation.Save(dataDir + "result.pptx", Aspose.Slides.Export.SaveFormat.Pptx);
            //ExEnd:SetTextFormattingInsideTable
        }
Пример #2
0
        public static void Run()
        {
            //ExStart:AddColumnsinTextFrame
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Text();

            string outPptxFileName = dataDir + "ColumnsTest.pptx";

            using (Presentation pres = new Presentation())
            {
                IAutoShape      shape1 = pres.Slides[0].Shapes.AddAutoShape(ShapeType.Rectangle, 100, 100, 300, 300);
                TextFrameFormat format = (TextFrameFormat)shape1.TextFrame.TextFrameFormat;

                format.ColumnCount    = 2;
                shape1.TextFrame.Text = "All these columns are limited to be within a single text container -- " +
                                        "you can add or delete text and the new or remaining text automatically adjusts " +
                                        "itself to flow within the container. You cannot have text flow from one container " +
                                        "to other though -- we told you PowerPoint's column options for text are limited!";
                pres.Save(outPptxFileName, SaveFormat.Pptx);

                using (Presentation test = new Presentation(outPptxFileName))
                {
                    Assert.AreEqual(2, ((AutoShape)test.Slides[0].Shapes[0]).TextFrame.TextFrameFormat.ColumnCount);
                    Assert.AreEqual(double.NaN, ((AutoShape)test.Slides[0].Shapes[0]).TextFrame.TextFrameFormat.ColumnSpacing);
                }

                format.ColumnSpacing = 20;
                pres.Save(outPptxFileName, SaveFormat.Pptx);

                using (Presentation test = new Presentation(outPptxFileName))
                {
                    Assert.AreEqual(2, ((AutoShape)test.Slides[0].Shapes[0]).TextFrame.TextFrameFormat.ColumnCount);
                    Assert.AreEqual(20, ((AutoShape)test.Slides[0].Shapes[0]).TextFrame.TextFrameFormat.ColumnSpacing);
                }

                format.ColumnCount   = 3;
                format.ColumnSpacing = 15;
                pres.Save(outPptxFileName, SaveFormat.Pptx);

                using (Presentation test = new Presentation(outPptxFileName))
                {
                    Assert.AreEqual(3, ((AutoShape)test.Slides[0].Shapes[0]).TextFrame.TextFrameFormat.ColumnCount);
                    Assert.AreEqual(15, ((AutoShape)test.Slides[0].Shapes[0]).TextFrame.TextFrameFormat.ColumnSpacing);
                }
            }

            //ExEnd:AddColumnsinTextFrame
        }