public static void Run()
        {
            //ExStart:ExtractEmbeddedFileDataFromOLEObject

            // The documents directory path.
            string dataDir = RunExamples.GetDataDir_Shapes();

            string pptxFileName = dataDir + "TestOlePresentation.pptx";

            using (Presentation pres = new Presentation(pptxFileName))
            {
                int objectnum = 0;
                foreach (ISlide sld in pres.Slides)
                {
                    foreach (IShape shape in sld.Shapes)
                    {
                        if (shape is OleObjectFrame)
                        {
                            objectnum++;
                            OleObjectFrame oleFrame      = shape as OleObjectFrame;
                            byte[]         data          = oleFrame.EmbeddedFileData;
                            string         fileExtention = oleFrame.EmbeddedFileExtension;

                            string extractedPath = dataDir + "ExtractedObject_out" + objectnum + fileExtention;
                            using (FileStream fs = new FileStream(extractedPath, FileMode.Create))
                            {
                                fs.Write(data, 0, data.Length);
                            }
                        }
                    }
                }
            }

            //ExEnd:ExtractEmbeddedFileDataFromOLEObject
        }
コード例 #2
0
        public static void Run()
        {
            //ExStart:AccessOLEObjectFrame
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Shapes();

            // Load the PPTX to Presentation object
            Presentation pres = new Presentation(dataDir + "AccessingOLEObjectFrame.pptx");

            // Access the first slide
            ISlide sld = pres.Slides[0];

            // Cast the shape to OleObjectFrame
            OleObjectFrame oof = (OleObjectFrame)sld.Shapes[0];

            // Read the OLE Object and write it to disk
            if (oof != null)
            {
                FileStream fstr = new FileStream(dataDir + "excelFromOLE_out.xlsx", FileMode.Create, FileAccess.Write);
                byte[]     buf  = oof.ObjectData;
                fstr.Write(buf, 0, buf.Length);
                fstr.Flush();
                fstr.Close();
            }
            //ExEnd:AccessOLEObjectFrame
        }
コード例 #3
0
        public static void Run()
        {
            //ExStart:ChangeOLEObjectData
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Shapes();

            Presentation pres = new Presentation(dataDir + "ChangeOLEObjectData.pptx");

            ISlide slide = pres.Slides[0];

            OleObjectFrame ole = null;

            // Traversing all shapes for Ole frame
            foreach (IShape shape in slide.Shapes)
            {
                if (shape is OleObjectFrame)
                {
                    ole = (OleObjectFrame)shape;
                }
            }

            if (ole != null)
            {
                // Reading object data in Workbook
                Aspose.Cells.Workbook Wb;

                using (System.IO.MemoryStream msln = new System.IO.MemoryStream(ole.ObjectData))
                {
                    Wb = new Aspose.Cells.Workbook(msln);

                    using (System.IO.MemoryStream msout = new System.IO.MemoryStream())
                    {
                        // Modifying the workbook data
                        Wb.Worksheets[0].Cells[0, 4].PutValue("E");
                        Wb.Worksheets[0].Cells[1, 4].PutValue(12);
                        Wb.Worksheets[0].Cells[2, 4].PutValue(14);
                        Wb.Worksheets[0].Cells[3, 4].PutValue(15);

                        Aspose.Cells.OoxmlSaveOptions so1 = new Aspose.Cells.OoxmlSaveOptions(Aspose.Cells.SaveFormat.Xlsx);

                        Wb.Save(msout, so1);

                        // Changing Ole frame object data
                        msout.Position = 0;
                        ole.ObjectData = msout.ToArray();
                    }
                }
            }

            pres.Save(dataDir + "OleEdit_out.pptx", SaveFormat.Pptx);
            //ExEnd:ChangeOLEObjectData
        }
コード例 #4
0
        public void OleObjectFrameAddByLink()
        {
            TestUtils.Upload(c_fileName, c_folderName + "/" + c_fileName);
            OleObjectFrame dto = new OleObjectFrame()
            {
                X            = 100,
                Y            = 100,
                Width        = 200,
                Height       = 200,
                LinkPath     = c_oleObjectFileName,
                ObjectProgId = "Excel.Sheet.8"
            };

            ShapeBase shape = TestUtils.SlidesApi.CreateShape(c_fileName, c_slideIndex, dto, password: c_password, folder: c_folderName);

            Assert.IsInstanceOf <OleObjectFrame>(shape);
            Assert.AreEqual(((OleObjectFrame)shape).LinkPath, dto.LinkPath);
        }
コード例 #5
0
        public void OleObjectFrameAddEmbedded()
        {
            TestUtils.Upload(c_fileName, c_folderName + "/" + c_fileName);
            Stream file = File.OpenRead(Path.Combine(TestUtils.TestDataPath, c_oleObjectFileName));

            byte[] buffer = new byte[file.Length];
            file.Read(buffer, 0, buffer.Length);

            OleObjectFrame dto = new OleObjectFrame()
            {
                X      = 100,
                Y      = 100,
                Width  = 200,
                Height = 200,
                EmbeddedFileBase64Data = Convert.ToBase64String(buffer),
                EmbeddedFileExtension  = "xlsx"
            };

            ShapeBase shape = TestUtils.SlidesApi.CreateShape(c_fileName, c_slideIndex, dto, password: c_password, folder: c_folderName);

            Assert.IsInstanceOf <OleObjectFrame>(shape);
            Assert.IsNotNull(((OleObjectFrame)shape).EmbeddedFileBase64Data);
            Assert.IsNotEmpty(((OleObjectFrame)shape).EmbeddedFileBase64Data);
        }