Class OleObject
Namespace: Aspose.Cells.Drawing
Assembly: Aspose.Cells.dll (25.2.0)
Represents an OleObject in a worksheet.
public class OleObject : Shape
Inheritance
Inherited Members
Shape.GetResultOfSmartArt(), Shape.ToFrontOrBack(int), Shape.GetLockedProperty(ShapeLockType), Shape.SetLockedProperty(ShapeLockType, bool), Shape.AddHyperlink(string), Shape.RemoveHyperlink(), Shape.MoveToRange(int, int, int, int), Shape.AlignTopRightCorner(int, int), Shape.GetConnectionPoints(), Shape.ToImage(Stream, ImageType), Shape.ToImage(string, ImageOrPrintOptions), Shape.ToImage(Stream, ImageOrPrintOptions), Shape.GetLinkedCell(bool, bool), Shape.SetLinkedCell(string, bool, bool), Shape.GetInputRange(bool, bool), Shape.SetInputRange(string, bool, bool), Shape.UpdateSelectedValue(), Shape.CalculateTextSize(), Shape.FormatCharacters(int, int, Font, StyleFlag), Shape.Characters(int, int), Shape.GetRichFormattings(), Shape.RemoveActiveXControl(), Shape.IsSameSetting(object), Shape.GetActualBox(), Shape.MacroName, Shape.IsEquation, Shape.IsSmartArt, Shape.ZOrderPosition, Shape.Name, Shape.AlternativeText, Shape.Title, Shape.Line, Shape.Fill, Shape.ShadowEffect, Shape.Reflection, Shape.Glow, Shape.SoftEdges, Shape.ThreeDFormat, Shape.FormatPicture, Shape.IsHidden, Shape.IsAspectRatioLocked, Shape.RotationAngle, Shape.Hyperlink, Shape.Id, Shape.Spid, Shape.Spt, Shape.Worksheet, Shape.IsGroup, Shape.IsInGroup, Shape.IsWordArt, Shape.TextEffect, Shape.IsLocked, Shape.IsPrintable, Shape.MsoDrawingType, Shape.AutoShapeType, Shape.AnchorType, Shape.Placement, Shape.UpperLeftRow, Shape.UpperDeltaY, Shape.UpperLeftColumn, Shape.UpperDeltaX, Shape.LowerRightRow, Shape.LowerDeltaY, Shape.LowerRightColumn, Shape.LowerDeltaX, Shape.Right, Shape.Bottom, Shape.Width, Shape.WidthInch, Shape.WidthPt, Shape.WidthCM, Shape.Height, Shape.HeightInch, Shape.HeightPt, Shape.HeightCM, Shape.Left, Shape.LeftInch, Shape.LeftCM, Shape.Top, Shape.TopInch, Shape.TopCM, Shape.TopToCorner, Shape.LeftToCorner, Shape.X, Shape.Y, Shape.WidthScale, Shape.HeightScale, Shape.TopInShape, Shape.LeftInShape, Shape.WidthInShape, Shape.HeightInShape, Shape.Group, Shape.Type, Shape.HasLine, Shape.IsFilled, Shape.IsFlippedHorizontally, Shape.IsFlippedVertically, Shape.ActualLowerRightRow, Shape.RelativeToOriginalPictureSize, Shape.LinkedCell, Shape.InputRange, Shape.TextShapeType, Shape.TextBody, Shape.Font, Shape.TextOptions, Shape.Text, Shape.IsRichText, Shape.HtmlText, Shape.TextVerticalOverflow, Shape.TextHorizontalOverflow, Shape.IsTextWrapped, Shape.TextOrientationType, Shape.TextHorizontalAlignment, Shape.TextVerticalAlignment, Shape.TextDirection, Shape.TextBoxOptions, Shape.ControlData, Shape.ActiveXControl, Shape.Paths, Shape.Geometry, Shape.CreateId, Shape.IsDecorative, object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Examples
//Instantiate a new Workbook.
Workbook workbook = new Workbook();
//Get the first worksheet.
Worksheet sheet = workbook.Worksheets[0];
//Define a string variable to store the image path.
string ImageUrl = "school.jpg";
//Get the picture into the streams.
FileStream fs = new FileStream(ImageUrl, FileMode.Open);
//Define a byte array.
byte[] imageData = new Byte[fs.Length];
//Obtain the picture into the array of bytes from streams.
fs.Read(imageData, 0, imageData.Length);
//Close the stream.
fs.Close();
//Get an excel file path in a variable.
string path = "Book1.xls";
//Get the file into the streams.
fs = new FileStream(path, FileMode.Open);
//Define an array of bytes.
byte[] objectData = new Byte[fs.Length];
//Store the file from streams.
fs.Read(objectData, 0, objectData.Length);
//Close the stream.
fs.Close();
//Add an Ole object into the worksheet with the image
//shown in MS Excel.
sheet.OleObjects.Add(14, 3, 200, 220, imageData);
//Set embedded ole object data.
sheet.OleObjects[0].ObjectData = objectData;
//Save the excel file
workbook.Save(@"oleobjects.xls");
'Instantiate a new Workbook.
Dim workbook As Workbook = New Workbook()
'Get the first worksheet.
Dim sheet As Worksheet = workbook.Worksheets(0)
'Define a string variable to store the image path.
Dim ImageUrl As String = @"school.jpg"
'Get the picture into the streams.
Dim fs As FileStream = File.OpenRead(ImageUrl)
'Define a byte array.
Dim imageData(fs.Length) As Byte
'Obtain the picture into the array of bytes from streams.
fs.Read(imageData, 0, imageData.Length)
'Close the stream.
fs.Close()
'Get an excel file path in a variable.
Dim path As String = @"Book1.xls"
'Get the file into the streams.
fs = File.OpenRead(path)
'Define an array of bytes.
Dim objectData(fs.Length) As Byte
'Store the file from streams.
fs.Read(objectData, 0, objectData.Length)
'Close the stream.
fs.Close()
'Add an Ole object into the worksheet with the image
'shown in MS Excel.
sheet.OleObjects.Add(14, 3, 200, 220, imageData)
'Set embedded ole object data.
sheet.OleObjects(0).ObjectData = objectData
'Save the excel file
workbook.Save("oleobjects.xls")
Properties
AutoLoad
Specifies whether the host application for the embedded object shall be called to load the object data automatically when the parent workbook is opened.
public bool AutoLoad { get; set; }
Property Value
AutoUpdate
Specifies whether the link to the OleObject is automatically updated or not.
public bool AutoUpdate { get; set; }
Property Value
ClassIdentifier
Gets and sets the class identifier of the embedded object. It means which application opens the embedded file.
public byte[] ClassIdentifier { get; set; }
Property Value
byte[]
DisplayAsIcon
True if the specified object is displayed as an icon and the image will not be auto changed.
public bool DisplayAsIcon { get; set; }
Property Value
FileFormatType
Gets and sets the file type of the embedded ole object data
public FileFormatType FileFormatType { get; set; }
Property Value
FullObjectBin
Gets the full embedded ole object binary data in the template file.
public byte[] FullObjectBin { get; }
Property Value
byte[]
ImageData
Represents image of ole object as byte array.
public byte[] ImageData { get; set; }
Property Value
byte[]
ImageSourceFullName
Gets or sets the path and name of the source file for the linked image.
public string ImageSourceFullName { get; set; }
Property Value
Remarks
The default value is an empty string. If SourceFullName is not an empty string, the image is linked. If SourceFullName is not an empty string, but Data is null, then the image is linked and not stored in the file.
ImageType
Gets the image format of the ole object.
public ImageType ImageType { get; }
Property Value
IsAutoSize
True indicates that the size of the ole object will be auto changed as the size of snapshot of the embedded content when the ole object is activated.
public bool IsAutoSize { get; set; }
Property Value
IsLink
Returns true if the OleObject links to the file.
public bool IsLink { get; set; }
Property Value
Label
Gets and sets the display label of the linked ole object.
public string Label { get; set; }
Property Value
ObjectData
Represents embedded ole object data as byte array.
public byte[] ObjectData { get; set; }
Property Value
byte[]
ObjectSourceFullName
Returns the source full name of the source file for the linked OLE object.
public string ObjectSourceFullName { get; set; }
Property Value
Remarks
Only supports setting the source full name when the file type is OleFileType.Unknown. Such as wav file ,avi file..etc..
ProgID
Gets or sets the ProgID of the OLE object.
public string ProgID { get; set; }
Property Value
Methods
SetEmbeddedObject(bool, byte[], string, bool, string)
Sets embedded object data.
public void SetEmbeddedObject(bool linkToFile, byte[] objectData, string sourceFileName, bool displayAsIcon, string label)
Parameters
linkToFile
bool
Indicates whether the object links to the file. If true, the parameter objectData is ignored.
objectData
byte[]
The embedded object data.
sourceFileName
string
The file name.
displayAsIcon
bool
Indicates whether diplaying object as an icon. If true, the orginal image data will be covered by icon.
label
string
The icon label. Only works when displayAsIcon as true.
SetEmbeddedObject(bool, byte[], string, bool, string, bool)
Sets embedded object data.
public void SetEmbeddedObject(bool linkToFile, byte[] objectData, string sourceFileName, bool displayAsIcon, string label, bool updateIcon)
Parameters
linkToFile
bool
Indicates whether the object links to the file. If true, the parameter objectData is ignored.
objectData
byte[]
The embedded object data.
sourceFileName
string
The file name.
displayAsIcon
bool
Indicates whether diplaying object as an icon. If true, the orginal image data will be covered by icon.
label
string
The icon label. Only works when displayAsIcon as true.
updateIcon
bool
Indicates whether automatically updating icon.
Remarks
As Aspose can update embedd all file icons, so it’s better that you can add correct icon with updateIcon
as false.
SetNativeSourceFullName(string)
Sets the ole native source full file name with path.
public void SetNativeSourceFullName(string sourceFullName)
Parameters
sourceFullName
string
the ole native source full file name