OleFormat Class
Provides access to the data of an OLE object or ActiveX control.
Inheritance Hierarchy
SystemObject
  Aspose.Words.DrawingOleFormat

Namespace: Aspose.Words.Drawing
Assembly: Aspose.Words (in Aspose.Words.dll) Version: 20.1
Syntax
public class OleFormat

The OleFormat type exposes the following members.

Properties
  NameDescription
Public propertyCode exampleAutoUpdate
Specifies whether the link to the OLE object is automatically updated or not in Microsoft Word.
Public propertyCode exampleClsid
Gets the CLSID of the OLE object.
Public propertyCode exampleIconCaption
Gets icon caption of OLE object.

In case of OLE object is not embedded as icon or caption couldn't be retrieved returns empty string.

Public propertyCode exampleIsLink
Returns true if the OLE object is linked (when SourceFullName is specified).
Public propertyCode exampleIsLocked
Specifies whether the link to the OLE object is locked from updates.
Public propertyCode exampleOleControl
Gets OleControl objects if this OLE object is an ActiveX control. Otherwise this property is null.
Public propertyCode exampleOleIcon
Gets the draw aspect of the OLE object. When true, the OLE object is displayed as an icon. When false, the OLE object is displayed as content.
Public propertyCode exampleOlePackage
Provide access to OlePackage if OLE object is an OLE Package. Returns null otherwise.
Public propertyCode exampleProgId
Gets or sets the ProgID of the OLE object.
Public propertyCode exampleSourceFullName
Gets or sets the path and name of the source file for the linked OLE object.
Public propertyCode exampleSourceItem
Gets or sets a string that is used to identify the portion of the source file that is being linked.
Public propertyCode exampleSuggestedExtension
Gets the file extension suggested for the current embedded object if you want to save it into a file.
Public propertyCode exampleSuggestedFileName
Gets the file name suggested for the current embedded object if you want to save it into a file.
Methods
  NameDescription
Public methodEquals (Inherited from Object.)
Protected methodFinalize (Inherited from Object.)
Public methodGetHashCode (Inherited from Object.)
Public methodCode exampleGetOleEntry
Gets OLE object data entry.
Public methodGetRawData
Gets OLE object raw data.
Public methodGetType (Inherited from Object.)
Protected methodMemberwiseClone (Inherited from Object.)
Public methodCode exampleSave(Stream)
Saves the data of the embedded object into the specified stream.
Public methodCode exampleSave(String)
Saves the data of the embedded object into a file with the specified name.
Public methodToString (Inherited from Object.)
Remarks

Use the OleFormat property to access the data of an OLE object. You do not create instances of the OleFormat class directly.

Examples
Shows how to extract embedded OLE objects into files.
Document doc = new Document(MyDir + "Shape.Ole.Spreadsheet.docm");

// The first shape will contain an OLE object
Shape shape = (Shape)doc.GetChild(NodeType.Shape, 0, true);

// This object is a Microsoft Excel spreadsheet
OleFormat oleFormat = shape.OleFormat;
Assert.AreEqual("Excel.Sheet.12", oleFormat.ProgId);

// Our object is neither auto updating nor locked from updates
Assert.False(oleFormat.AutoUpdate);
Assert.AreEqual(false, oleFormat.IsLocked);

// If we want to extract the OLE object by saving it into our local file system, this property can tell us the relevant file extension
Assert.AreEqual(".xlsx", oleFormat.SuggestedExtension);

// We can save it via a stream
using (FileStream fs = new FileStream(ArtifactsDir + "OLE spreadsheet extracted via stream" + oleFormat.SuggestedExtension, FileMode.Create))
{
    oleFormat.Save(fs);
}

// We can also save it directly to a file
oleFormat.Save(ArtifactsDir + "OLE spreadsheet saved directly" + oleFormat.SuggestedExtension);
See Also