OleFormatGetOleEntry Method

Gets OLE object data entry.

Namespace:  Aspose.Words.Drawing
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.3
Syntax
public MemoryStream GetOleEntry(
	string oleEntryName
)

Parameters

oleEntryName
Type: SystemString
Case-sensitive name of the OLE data stream.

Return Value

Type: MemoryStream
An OLE data stream or null.
Examples
Shows how to insert linked and unlinked OLE objects.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Embed a Microsoft Visio drawing as an OLE object into the document
builder.InsertOleObject(ImageDir + "Microsoft Visio drawing.vsd", "Package", false, false, null);

// Insert a link to the file in the local file system and display it as an icon
builder.InsertOleObject(ImageDir + "Microsoft Visio drawing.vsd", "Package", true, true, null);

// Both the OLE objects are stored within shapes
List<Shape> shapes = doc.GetChildNodes(NodeType.Shape, true).Cast<Shape>().ToList();
Assert.AreEqual(2, shapes.Count);

// If the shape is an OLE object, it will have a valid OleFormat property
// We can use it check if it is linked or displayed as an icon, among other things
OleFormat oleFormat = shapes[0].OleFormat;
Assert.AreEqual(false, oleFormat.IsLink);
Assert.AreEqual(false, oleFormat.OleIcon);

oleFormat = shapes[1].OleFormat;
Assert.AreEqual(true, oleFormat.IsLink);
Assert.AreEqual(true, oleFormat.OleIcon);

// Get the name or the source file and verify that the whole file is linked
Assert.True(oleFormat.SourceFullName.EndsWith(@"Images" + Path.DirectorySeparatorChar + "Microsoft Visio drawing.vsd"));
Assert.AreEqual("", oleFormat.SourceItem);

Assert.AreEqual("Packager", oleFormat.IconCaption);

doc.Save(ArtifactsDir + "Shape.OleLinks.docx");

// We can get a stream with the OLE data entry, if the object has this
using (MemoryStream stream = oleFormat.GetOleEntry("\x0001CompObj"))
{
    byte[] oleEntryBytes = stream.ToArray();
    Assert.AreEqual(76, oleEntryBytes.Length);
}
See Also