public class OleObject extends Shape
Example
//Instantiate a new Workbook.
Workbook workbook = new Workbook();
//Get the first worksheet.
Worksheet sheet = workbook.getWorksheets().get(0);
//Define a string variable to store the image path.
String ImageUrl = "school.jpg";
//Get the picture into the streams.
FileInputStream fs = new FileInputStream(ImageUrl);
//Define a byte array.
byte[] imageData = new byte[fs.available()];
//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 FileInputStream(path);
//Define an array of bytes.
byte[] objectData = new byte[fs.available()];
//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.getOleObjects().add(14, 3, 200, 220, imageData);
//Set embedded ole object data.
sheet.getOleObjects().get(0).setObjectData(objectData);
//Save the excel file
workbook.save("oleobjects.xls");
| Modifier and Type | Method and Description |
|---|---|
boolean |
getAutoLoad()
Specifies whether the host application for the embedded object shall be called to load
the object data automatically when the parent workbook is opened.
|
boolean |
getAutoUpdate()
Specifies whether the link to the OleObject is automatically updated or not.
|
byte[] |
getClassIdentifier()
Gets the class identifier of the embedded object.
|
boolean |
getDisplayAsIcon()
True if the specified object is displayed as an icon
and the image will not be auto changed.
|
int |
getFileFormatType()
Gets the file type of the embedded ole object data
|
byte[] |
getFullObjectBin()
Gets the full embedded ole object binary data in the template file.
|
byte[] |
getImageData()
Represents image of ole object as byte array.
|
java.lang.String |
getImageSourceFullName()
Gets the path and name of the source file for the linked image.
|
int |
getImageType()
Gets the image format of the ole object.
|
java.lang.String |
getLabel()
Gets the display label of the linked ole object.
|
byte[] |
getObjectData()
Represents embedded ole object data as byte array.
|
java.lang.String |
getObjectSourceFullName()
Returns the source full name of the source file for the linked OLE object.
|
java.lang.String |
getProgID()
Gets the ProgID of the OLE object.
|
java.lang.String |
getSourceFullName()
Deprecated.
Use OleObject.ObjectSourceFullName property instead.
|
boolean |
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.
|
boolean |
isLink()
Returns true if the OleObject links to the file.
|
void |
setAutoLoad(boolean value)
Specifies whether the host application for the embedded object shall be called to load
the object data automatically when the parent workbook is opened.
|
void |
setAutoSize(boolean value)
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.
|
void |
setAutoUpdate(boolean value)
Specifies whether the link to the OleObject is automatically updated or not.
|
void |
setClassIdentifier(byte[] value)
Sets the class identifier of the embedded object.
|
void |
setDisplayAsIcon(boolean value)
True if the specified object is displayed as an icon
and the image will not be auto changed.
|
void |
setEmbeddedObject(boolean linkToFile,
byte[] objectData,
java.lang.String sourceFileName,
boolean displayAsIcon,
java.lang.String label)
Sets embedded object data.
|
void |
setEmbeddedObject(boolean linkToFile,
byte[] objectData,
java.lang.String sourceFileName,
boolean displayAsIcon,
java.lang.String label,
boolean updateIcon)
Sets embedded object data.
|
void |
setFileFormatType(int value)
Sets the file type of the embedded ole object data
|
void |
setImageData(byte[] value)
Represents image of ole object as byte array.
|
void |
setImageSourceFullName(java.lang.String value)
Sets the path and name of the source file for the linked image.
|
void |
setLabel(java.lang.String value)
Sets the display label of the linked ole object.
|
void |
setLink(boolean value)
Returns true if the OleObject links to the file.
|
void |
setNativeSourceFullName(java.lang.String sourceFullName)
Sets the ole native source full file name with path.
|
void |
setObjectData(byte[] value)
Represents embedded ole object data as byte array.
|
void |
setObjectSourceFullName(java.lang.String value)
Returns the source full name of the source file for the linked OLE object.
|
void |
setProgID(java.lang.String value)
Sets the ProgID of the OLE object.
|
void |
setSourceFullName(java.lang.String value)
Deprecated.
Use OleObject.ObjectSourceFullName property instead.
|
addHyperlink, alignTopRightCorner, calculateTextSize, characters, fitToTextSize, formatCharacters, getActiveXControl, getActualBox, getActualLowerRightRow, getAlternativeText, getAnchorType, getAutoShapeType, getBottom, getCharacters, getConnectionPoints, getControlData, getCreateId, getFill, getFillFormat, getFont, getFormatPicture, getGeometry, getGlow, getGroup, getHeight, getHeightCM, getHeightInch, getHeightInShape, getHeightPt, getHeightScale, getHtmlText, getHyperlink, getId, getInputRange, getInputRange, getLeft, getLeftCM, getLeftInch, getLeftInShape, getLeftToCorner, getLine, getLineFormat, getLinkedCell, getLinkedCell, getLockedProperty, getLowerDeltaX, getLowerDeltaY, getLowerRightColumn, getLowerRightRow, getMacroName, getMsoDrawingType, getName, getPaths, getPlacement, getReflection, getRelativeToOriginalPictureSize, getResultOfSmartArt, getRichFormattings, getRight, getRotationAngle, getShadowEffect, getSoftEdges, getSpid, getSpt, getText, getTextBody, getTextBoxOptions, getTextDirection, getTextEffect, getTextHorizontalAlignment, getTextHorizontalOverflow, getTextOptions, getTextOrientationType, getTextShapeType, getTextVerticalAlignment, getTextVerticalOverflow, getThreeDFormat, getTitle, getTop, getTopCM, getTopInch, getTopInShape, getTopToCorner, getType, getUpperDeltaX, getUpperDeltaY, getUpperLeftColumn, getUpperLeftRow, getWidth, getWidthCM, getWidthInch, getWidthInShape, getWidthPt, getWidthScale, getWorksheet, getX, getY, getZOrderPosition, hasLine, isAspectRatioLocked, isDecorative, isEquation, isFilled, isFlippedHorizontally, isFlippedVertically, isGroup, isHidden, isInGroup, isLockAspectRatio, isLocked, isPrintable, isRichText, isSameSetting, isSmartArt, isTextWrapped, isWordArt, moveToRange, removeActiveXControl, removeHyperlink, setAlternativeText, setAnchorType, setAspectRatioLocked, setAutoShapeType, setBottom, setCreateId, setDecorative, setFilled, setFlippedHorizontally, setFlippedVertically, setFont, setHasLine, setHeight, setHeightCM, setHeightInch, setHeightInShape, setHeightPt, setHeightScale, setHidden, setHtmlText, setInputRange, setInputRange, setLeft, setLeftCM, setLeftInch, setLeftInShape, setLeftToCorner, setLinkedCell, setLinkedCell, setLockAspectRatio, setLocked, setLockedProperty, setLowerDeltaX, setLowerDeltaY, setLowerRightColumn, setLowerRightRow, setMacroName, setName, setPlacement, setPrintable, setRelativeToOriginalPictureSize, setRight, setRotationAngle, setSoftEdges, setText, setTextDirection, setTextHorizontalAlignment, setTextHorizontalOverflow, setTextOptions, setTextOrientationType, setTextShapeType, setTextVerticalAlignment, setTextVerticalOverflow, setTextWrapped, setTitle, setTop, setTopCM, setTopInch, setTopInShape, setTopToCorner, setUpperDeltaX, setUpperDeltaY, setUpperLeftColumn, setUpperLeftRow, setWidth, setWidthCM, setWidthInch, setWidthInShape, setWidthPt, setWidthScale, setX, setY, setZOrderPosition, toFrontOrBack, toImage, toImage, toImage, updateSelectedValuepublic void setEmbeddedObject(boolean linkToFile,
byte[] objectData,
java.lang.String sourceFileName,
boolean displayAsIcon,
java.lang.String label)
linkToFile - Indicates whether the object links to the file. If true, the parameter objectData is ignored.objectData - The embedded object data.sourceFileName - The file name.displayAsIcon - Indicates whether diplaying object as an icon.
If true, the orginal image data will be covered by icon.label - The icon label. Only works when displayAsIcon as true.public void setEmbeddedObject(boolean linkToFile,
byte[] objectData,
java.lang.String sourceFileName,
boolean displayAsIcon,
java.lang.String label,
boolean updateIcon)
Remarks
As Aspose can update embedd all file icons, so it's better that you can add correct icon withlinkToFile - Indicates whether the object links to the file. If true, the parameter objectData is ignored.objectData - The embedded object data.sourceFileName - The file name.displayAsIcon - Indicates whether diplaying object as an icon.
If true, the orginal image data will be covered by icon.label - The icon label. Only works when displayAsIcon as true.updateIcon - Indicates whether automatically updating icon.public boolean isAutoSize()
public void setAutoSize(boolean value)
public boolean isLink()
public void setLink(boolean value)
public boolean getDisplayAsIcon()
public void setDisplayAsIcon(boolean value)
public byte[] getImageData()
public void setImageData(byte[] value)
public byte[] getObjectData()
public void setObjectData(byte[] value)
public byte[] getFullObjectBin()
public java.lang.String getImageSourceFullName()
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.public void setImageSourceFullName(java.lang.String 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.public void setNativeSourceFullName(java.lang.String sourceFullName)
sourceFullName - the ole native source full file namepublic java.lang.String getProgID()
public void setProgID(java.lang.String value)
public int getFileFormatType()
See FileFormatType.
public void setFileFormatType(int value)
See FileFormatType.
public java.lang.String getObjectSourceFullName()
Remarks
Only supports setting the source full name when the file type is OleFileType.Unknown. Such as wav file ,avi file..etc..public void setObjectSourceFullName(java.lang.String value)
Remarks
Only supports setting the source full name when the file type is OleFileType.Unknown. Such as wav file ,avi file..etc..public java.lang.String getLabel()
public void setLabel(java.lang.String value)
public java.lang.String getSourceFullName()
Remarks
NOTE: This member is now obsolete. Instead, please use OleObject.ObjectSourceFullName property. This property will be removed 12 months later since November 2013. Aspose apologizes for any inconvenience you may have experienced.public void setSourceFullName(java.lang.String value)
Remarks
NOTE: This member is now obsolete. Instead, please use OleObject.ObjectSourceFullName property. This property will be removed 12 months later since November 2013. Aspose apologizes for any inconvenience you may have experienced.public boolean getAutoUpdate()
public void setAutoUpdate(boolean value)
public boolean getAutoLoad()
public void setAutoLoad(boolean value)
public byte[] getClassIdentifier()
public void setClassIdentifier(byte[] value)
public int getImageType()
See ImageType.
See Also:
Aspose.Cells Documentation - the home page for the Aspose.Cells Product Documentation.
Aspose.Cells Support Forum - our preferred method of support.
We guarantee a prompt response to any inquiry!
© Aspose Pty Ltd 2003-2025. All Rights Reserved.