OleFormatSourceItem Property |
Namespace: Aspose.Words.Drawing
The default value is an empty string.
For example, if the source file is a Microsoft Excel workbook, the SourceItem property might return "Workbook1!R3C1:R4C2" if the OLE object contains only a few cells from the worksheet.
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); }