Пример #1
0
        private void convertButton_Click(object sender, RibbonControlEventArgs e)
        {
            Excel.Worksheet currentSheet = Globals.ThisAddIn.GetActiveWorksheet();
            //  Excel.Workbook workbook = Globals.ThisAddIn.GetActiveWorkbook();
            Excel.Shapes shapes = currentSheet.Shapes;
            string       a      = null;

            foreach (Excel.Shape item in shapes)
            {
                a = item.Name;
            }
            Excel.Shape   shape = shapes.Item(a);
            SmartArt      smart = shape.SmartArt;
            SmartArtNodes nodes = smart.AllNodes;

            List <TextFrame2> textFrame2s = new List <TextFrame2>();

            foreach (SmartArtNode node in nodes)
            {
                textFrame2s.Add(node.TextFrame2);
            }
            TextRange2    range;
            List <string> strings = new List <string>();

            foreach (TextFrame2 textframe2 in textFrame2s)
            {
                range = textframe2.TextRange;
                strings.Add(range.Text);
            }
        }
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_SmartArts();

            //Load the desired the presentation
            Presentation pres = new Presentation(dataDir + "RemoveNodesSpecificPosition.pptx");

            //Traverse through every shape inside first slide
            foreach (IShape shape in pres.Slides[0].Shapes)
            {
                //Check if shape is of SmartArt type
                if (shape is SmartArt)
                {
                    //Typecast shape to SmartArt
                    SmartArt smart = (SmartArt)shape;

                    if (smart.AllNodes.Count > 0)
                    {
                        //Accessing SmartArt node at index 0
                        ISmartArtNode node = smart.AllNodes[0];

                        if (node.ChildNodes.Count >= 2)
                        {
                            //Removing the child node at position 1
                            ((SmartArtNodeCollection)node.ChildNodes).RemoveNodeByPosition(1);
                        }
                    }
                }
            }

            //Save Presentation
            pres.Save(dataDir + "RemoveSmartArtNodeByPosition.pptx", Aspose.Slides.Export.SaveFormat.Pptx);
        }
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_SmartArts();

            //Load the desired the presentation
            //Load the desired the presentation
            Presentation pres = new Presentation(dataDir + "AccessSmartArt.pptx");

            //Traverse through every shape inside first slide
            foreach (IShape shape in pres.Slides[0].Shapes)
            {

                //Check if shape is of SmartArt type
                if (shape is SmartArt)
                {

                    //Typecast shape to SmartArt
                    SmartArt smart = (SmartArt)shape;

                    //Traverse through all nodes inside SmartArt
                    for (int i = 0; i < smart.AllNodes.Count; i++)
                    {
                        //Accessing SmartArt node at index i
                        SmartArtNode node = (SmartArtNode)smart.AllNodes[i];

                        //Printing the SmartArt node parameters
                        string outString = string.Format("i = {0}, Text = {1},  Level = {2}, Position = {3}", i, node.TextFrame.Text, node.Level, node.Position);
                        Console.WriteLine(outString);
                    }
                }
            }
            
            
        }
Пример #4
0
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_SmartArts();

            //Load the desired the presentation//Load the desired the presentation
            Presentation pres = new Presentation(dataDir + "AddNodes.pptx");

            //Traverse through every shape inside first slide
            foreach (IShape shape in pres.Slides[0].Shapes)
            {
                //Check if shape is of SmartArt type
                if (shape is SmartArt)
                {
                    //Typecast shape to SmartArt
                    SmartArt smart = (SmartArt)shape;

                    //Adding a new SmartArt Node
                    SmartArtNode TemNode = (SmartArtNode)smart.AllNodes.AddNode();

                    //Adding text
                    TemNode.TextFrame.Text = "Test";

                    //Adding new child node in parent node. It  will be added in the end of collection
                    SmartArtNode newNode = (SmartArtNode)TemNode.ChildNodes.AddNode();

                    //Adding text
                    newNode.TextFrame.Text = "New Node Added";
                }
            }

            //Saving Presentation
            pres.Save(dataDir + "AddSmartArtNode.pptx", Aspose.Slides.Export.SaveFormat.Pptx);
        }
        public void SmartArtAdd()
        {
            TestUtils.Upload(c_fileName, c_folderName + "/" + c_fileName);
            ShapeBase dto = new SmartArt
            {
                X          = 0,
                Y          = 0,
                Width      = 300,
                Height     = 200,
                Layout     = SmartArt.LayoutEnum.BasicProcess,
                QuickStyle = SmartArt.QuickStyleEnum.SimpleFill,
                ColorStyle = SmartArt.ColorStyleEnum.ColoredFillAccent1,
                Nodes      = new List <SmartArtNode>
                {
                    new SmartArtNode
                    {
                        Text           = "First",
                        OrgChartLayout = SmartArtNode.OrgChartLayoutEnum.Initial,
                        Nodes          = new List <SmartArtNode>
                        {
                            new SmartArtNode {
                                Text = "SubFirst", OrgChartLayout = SmartArtNode.OrgChartLayoutEnum.Initial
                            }
                        }
                    },
                    new SmartArtNode {
                        Text = "Second", OrgChartLayout = SmartArtNode.OrgChartLayoutEnum.Initial
                    }
                }
            };
            ShapeBase shape = TestUtils.SlidesApi.CreateShape(c_fileName, c_slideIndex, dto, password: c_password, folder: c_folderName);

            Assert.IsInstanceOf <SmartArt>(shape);
        }