Module: Asposeslidesjava::OleObject

Defined in:
lib/asposeslidesjava/Shapes/oleobject.rb

Instance Method Summary collapse

Instance Method Details

#initializeObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/asposeslidesjava/Shapes/oleobject.rb', line 3

def initialize()
    data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/Shapes/'
            
    # Create an instance of Presentation class
    pres = Rjb::import('com.aspose.slides.Presentation').new(data_dir + 'OleEmbed.pptx')

    # Get the first slide
    sld = pres.getSlides().get_Item(0)

    # Cast the shape to OleObjectFrameEx
    oof = sld.getShapes().get_Item(0)

    # Read the OLE Object and write it to disk
    if oof != nil
        fstr = Rjb::import('java.io.FileOutputStream').new(data_dir + "excelFromOLEObject.xlsx")
        buf = oof.getObjectData()
        fstr.write(buf, 0, buf.length)
        fstr.flush()
        fstr.close()
        puts "Excel OLE Object written as excelFromOLEObject.xlsx file"
    end
end