Interface IOleObject
Represent the Ole object shapes.
Namespace: Syncfusion.XlsIO
Assembly: Syncfusion.XlsIO.UWP.dll
Syntax
public interface IOleObject
Properties
DisplayAsIcon
Gets or sets a value indicating whether [display as icon].
Declaration
bool DisplayAsIcon { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
Examples
The following code illustrates how to set DisplayAsIcon
property.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet worksheet = workbook.Worksheets[0];
//Create image stream
System.Drawing.Image image = System.Drawing.Image.FromFile("image.png");
//Add ole object
IOleObject oleObject = worksheet.OleObjects.Add("Shapes.xlsx", image, OleLinkType.Embed);
//Set display as icon
oleObject.DisplayAsIcon = true;
//Save and dispose
workbook.SaveAs("OLEObjects.xlsx");
workbook.Close();
}
Location
Gets or sets the location.
Declaration
IRange Location { get; set; }
Property Value
Type | Description |
---|---|
IRange | The location. |
Examples
The following code illustrates how to set the Location
property.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet worksheet = workbook.Worksheets[0];
//Create image stream
System.Drawing.Image image = System.Drawing.Image.FromFile("image.png");
//Add ole object
IOleObject oleObject = worksheet.OleObjects.Add("Shapes.xlsx", image, OleLinkType.Embed);
//Set height and width
oleObject.Shape.Height = 150;
oleObject.Shape.Width = 150;
//Set location
oleObject.Location = worksheet["C7"];
//Save and dispose
workbook.SaveAs("OLEObjects.xlsx");
workbook.Close();
}
Name
Gets the name of an OLE object.
Declaration
string Name { get; }
Property Value
Type |
---|
System.String |
Examples
The following code illustrates how to access Name
property.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet worksheet = workbook.Worksheets[0];
//Create image stream
System.Drawing.Image image = System.Drawing.Image.FromFile("image.png");
//Add ole object
IOleObject oleObject = worksheet.OleObjects.Add("Shapes.xlsx", image, OleLinkType.Embed);
//Get name
Console.WriteLine(oleObject.Name);
//Save and dispose
workbook.SaveAs("OLEObjects.xlsx");
workbook.Close();
Console.ReadKey();
}
//Output will be
//Picture0
Picture
Gets or sets the picture.
Declaration
Image Picture { get; }
Property Value
Type | Description |
---|---|
Image | The picture. |
Examples
The following code illustrates how to access Picture
property.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet worksheet = workbook.Worksheets[0];
//Create image stream
System.Drawing.Image image = System.Drawing.Image.FromFile("image.png");
//Add ole object
IOleObject oleObject = worksheet.OleObjects.Add("Shapes.xlsx", image, OleLinkType.Embed);
//Get picture's height and width
Console.WriteLine(oleObject.Picture.Height);
Console.WriteLine(oleObject.Picture.Width);
//Save and dispose
workbook.SaveAs("OLEObjects.xlsx");
workbook.Close();
Console.ReadKey();
}
//Output will be
//{Given image's height}
//{Given image's width}
Shape
Gets or sets picture shape object that defines look and position of the OleObject inside parent worksheet.
Declaration
IPictureShape Shape { get; }
Property Value
Type |
---|
IPictureShape |
Examples
The following code illustrates how to set HeightDouble and WidthDouble of the Picture by accessing Shapes
property.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet worksheet = workbook.Worksheets[0];
//Create image stream
System.Drawing.Image image = System.Drawing.Image.FromFile("image.png");
//Add ole object
IOleObject oleObject = worksheet.OleObjects.Add("Shapes.xlsx", image, OleLinkType.Embed);
//Set height and width
oleObject.Shape.HeightDouble = 150;
oleObject.Shape.WidthDouble = 150;
//Save and dispose
workbook.SaveAs("OLEObjects.xlsx");
workbook.Close();
}
Size
Gets or sets the size.
Declaration
Size Size { get; set; }
Property Value
Type | Description |
---|---|
Size | The size. |
Examples
The following code illustrates how to access Size
property.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet worksheet = workbook.Worksheets[0];
//Create image stream
System.Drawing.Image image = System.Drawing.Image.FromFile("image.png");
//Add ole object
IOleObject oleObject = worksheet.OleObjects.Add("Shapes.xlsx", image, OleLinkType.Embed);
//Get image size
Console.WriteLine(oleObject.Size.Height);
Console.WriteLine(oleObject.Size.Width);
//Save and dispose
workbook.SaveAs("OLEObjects.xlsx");
workbook.Close();
Console.ReadKey();
}
//Output will be
//{Prints given image's height}
//{Prints given image's width}