public class Picture extends Shape
Example
//Instantiating a Workbook object
Workbook workbook = new Workbook();
//Adding a new worksheet to the Workbook object
int sheetIndex = workbook.getWorksheets().add();
//Obtaining the reference of the newly added worksheet by passing its sheet index
Worksheet worksheet = workbook.getWorksheets().get(sheetIndex);
//Adding a picture at the location of a cell whose row and column indices
//are 5 in the worksheet. It is "F6" cell
worksheet.getPictures().add(5, 5, "image.gif");
//Saving the Excel file
workbook.save("book1.xls", SaveFormat.EXCEL_97_TO_2003);
| Modifier and Type | Method and Description |
|---|---|
void |
copy(Picture source,
CopyOptions options)
Copy the picture.
|
Color |
getBorderLineColor()
Represents the
Color of the border line of a picture. |
double |
getBorderWeight()
Gets the weight of the border line of a picture in units of pt.
|
byte[] |
getData()
Gets the data of the picture.
|
boolean |
getDisplayAsIcon()
True if the specified object is displayed as an icon
and the image will not be auto changed.
|
java.lang.String |
getFormula()
Gets the data of the formula.
|
int |
getImageType()
Gets the image format of the picture.
|
int |
getOriginalHeight()
Gets the original height of the picture.
|
double |
getOriginalHeightCM()
Gets the original height of picture, in unit of centimeters.
|
double |
getOriginalHeightInch()
Gets the original height of picture, in unit of inches.
|
int |
getOriginalWidth()
Gets the original width of the picture.
|
double |
getOriginalWidthCM()
Gets the original width of picture, in unit of centimeters.
|
double |
getOriginalWidthInch()
Gets the original width of picture, in unit of inches.
|
SignatureLine |
getSignatureLine()
Gets the signature line
|
java.lang.String |
getSourceFullName()
Gets the path and name of the source file for the linked image.
|
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 |
isDynamicDataExchange()
Gets whether dynamic data exchange
|
boolean |
isLink()
Returns true if the picture is linked to a file.
|
boolean |
isSameSetting(java.lang.Object obj)
Returns whether the shape is same.
|
void |
move(int upperLeftRow,
int upperLeftColumn)
Moves the picture to a specified location.
|
void |
placeInCell()
Place this picture in the cell
|
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 |
setBorderLineColor(Color value)
Represents the
Color of the border line of a picture. |
void |
setBorderWeight(double value)
Sets the weight of the border line of a picture in units of pt.
|
void |
setData(byte[] value)
Gets the data of the picture.
|
void |
setDisplayAsIcon(boolean value)
True if the specified object is displayed as an icon
and the image will not be auto changed.
|
void |
setDynamicDataExchange(boolean value)
Sets whether dynamic data exchange
|
void |
setFormula(java.lang.String value)
Sets the data of the formula.
|
void |
setLink(boolean value)
Returns true if the picture is linked to a file.
|
void |
setSignatureLine(SignatureLine value)
Sets the signature line
|
void |
setSourceFullName(java.lang.String value)
Sets the path and name of the source file for the linked image.
|
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, 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 copy(Picture source, CopyOptions options)
Example
//Instantiating a Workbook object
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.getWorksheets().get(0);
//insert first picture
int imgIndex1 = worksheet.getPictures().add(1, 1, "1.png");
//Get the inserted picture object
Picture pic1 = worksheet.getPictures().get(imgIndex1);
//insert second picture
int imgIndex2 = worksheet.getPictures().add(1, 9, "2.jpeg");
//Get the inserted picture object
Picture pic2 = worksheet.getPictures().get(imgIndex2);
//Copy picture 1 to picture 2.You'll get two picture 1 objects that are superimposed on top of each other.
CopyOptions opt = new CopyOptions();
pic2.copy(pic1, opt);
//Save the excel file.
workbook.save("result.xlsx");
source - The source picture.options - The copy options.public void move(int upperLeftRow,
int upperLeftColumn)
Example
//Instantiating a Workbook object
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.getWorksheets().get(0);
//Adding a picture at the location of a cell whose row and column indices are 1 in the worksheet. It is "B2" cell
int imgIndex = worksheet.getPictures().add(1, 1, "example.jpeg");
//Get the inserted picture object
Picture pic = worksheet.getPictures().get(imgIndex);
//Set the new location of the picture
pic.move(2, 4);
//Save the excel file.
workbook.save("result.xlsx");
upperLeftRow - Upper left row index.upperLeftColumn - Upper left column index.public void placeInCell()
public int getOriginalHeight()
Example
//Instantiating a Workbook object
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.getWorksheets().get(0);
//Adding a picture at the location of a cell whose row and column indices are 1 in the worksheet. It is "B2" cell
int imgIndex = worksheet.getPictures().add(1, 1, "example.jpeg");
//Get the inserted picture object
Picture pic = worksheet.getPictures().get(imgIndex);
//Gets the original height of the picture.
int picHeight = pic.getOriginalHeight();
//Save the excel file.
workbook.save("result.xlsx");
public int getOriginalWidth()
Example
//Instantiating a Workbook object
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.getWorksheets().get(0);
//Adding a picture at the location of a cell whose row and column indices are 1 in the worksheet. It is "B2" cell
int imgIndex = worksheet.getPictures().add(1, 1, "example.jpeg");
//Get the inserted picture object
Picture pic = worksheet.getPictures().get(imgIndex);
//Gets the original width of the picture.
int picWidth = pic.getOriginalWidth();
//Save the excel file.
workbook.save("result.xlsx");
public Color getBorderLineColor()
Color of the border line of a picture.
Example
//Instantiating a Workbook object
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.getWorksheets().get(0);
//Adding a picture at the location of a cell whose row and column indices are 1 in the worksheet. It is "B2" cell
int imgIndex = worksheet.getPictures().add(1, 1, "example.jpeg");
//Get the inserted picture object
Picture pic = worksheet.getPictures().get(imgIndex);
//Set the border color of the picture
pic.setBorderLineColor(Color.getRed());
//Save the excel file.
workbook.save("result.xlsx");
public void setBorderLineColor(Color value)
Color of the border line of a picture.public double getBorderWeight()
Example
//Instantiating a Workbook object
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.getWorksheets().get(0);
//Adding a picture at the location of a cell whose row and column indices are 1 in the worksheet. It is "B2" cell
int imgIndex = worksheet.getPictures().add(1, 1, "example.jpeg");
//Get the inserted picture object
Picture pic = worksheet.getPictures().get(imgIndex);
//Set the border color of the picture
pic.setBorderLineColor(Color.getRed());
//Set the border width of the picture
pic.setBorderWeight(3);
//Save the excel file.
workbook.save("result.xlsx");
public void setBorderWeight(double value)
public byte[] getData()
Example
//Instantiating a Workbook object
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.getWorksheets().get(0);
//insert first picture
int imgIndex1 = worksheet.getPictures().add(1, 1, "example1.png");
//Get the inserted picture object
Picture pic1 = worksheet.getPictures().get(imgIndex1);
//insert second picture
int imgIndex2 = worksheet.getPictures().add(1, 9, "example2.jpeg");
//Get the inserted picture object
Picture pic2 = worksheet.getPictures().get(imgIndex2);
//Assign the byte data of the first image to the second image
pic2.setData(pic1.getData());
//Save the excel file.
workbook.save("result.xlsx");
public void setData(byte[] value)
public java.lang.String getSourceFullName()
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 setSourceFullName(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 java.lang.String getFormula()
public void setFormula(java.lang.String value)
public boolean isAutoSize()
public void setAutoSize(boolean value)
public boolean isLink()
public void setLink(boolean value)
public boolean isDynamicDataExchange()
public void setDynamicDataExchange(boolean value)
public boolean getDisplayAsIcon()
public void setDisplayAsIcon(boolean value)
public int getImageType()
See ImageType.
Example
//Instantiating a Workbook object
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.getWorksheets().get(0);
//insert first picture
int imgIndex1 = worksheet.getPictures().add(1, 1, "1.png");
//Get the inserted picture object
Picture pic1 = worksheet.getPictures().get(imgIndex1);
if(pic1.getImageType() == com.aspose.cells.ImageType.PNG)
{
//The picture's type is png.";
}
//insert second picture
int imgIndex2 = worksheet.getPictures().add(1, 9, "2.jpeg");
//Get the inserted picture object
Picture pic2 = worksheet.getPictures().get(imgIndex2);
if(pic2.getImageType() == com.aspose.cells.ImageType.JPEG)
{
//The picture's type is jpg.";
}
public double getOriginalHeightCM()
Example
//Instantiating a Workbook object
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.getWorksheets().get(0);
//Adding a picture at the location of a cell whose row and column indices are 1 in the worksheet. It is "B2" cell
int imgIndex = worksheet.getPictures().add(1, 1, "example.jpeg");
//Get the inserted picture object
Picture pic = worksheet.getPictures().get(imgIndex);
//Gets the original height of the picture.
double picHeightCM = pic.getOriginalHeightCM();
//Save the excel file.
workbook.save("result.xlsx");
public double getOriginalWidthCM()
Example
//Instantiating a Workbook object
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.getWorksheets().get(0);
//Adding a picture at the location of a cell whose row and column indices are 1 in the worksheet. It is "B2" cell
int imgIndex = worksheet.getPictures().add(1, 1, "example.jpeg");
//Get the inserted picture object
Picture pic = worksheet.getPictures().get(imgIndex);
//Gets the original width of the picture.
double picWidthCM = pic.getOriginalWidthCM();
//Save the excel file.
workbook.save("result.xlsx");
public double getOriginalHeightInch()
Example
//Instantiating a Workbook object
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.getWorksheets().get(0);
//Adding a picture at the location of a cell whose row and column indices are 1 in the worksheet. It is "B2" cell
int imgIndex = worksheet.getPictures().add(1, 1, "example.jpeg");
//Get the inserted picture object
Picture pic = worksheet.getPictures().get(imgIndex);
//Gets the original height of the picture.
double picHeightInch = pic.getOriginalHeightInch();
//Save the excel file.
workbook.save("result.xlsx");
public double getOriginalWidthInch()
Example
//Instantiating a Workbook object
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.getWorksheets().get(0);
//Adding a picture at the location of a cell whose row and column indices are 1 in the worksheet. It is "B2" cell
int imgIndex = worksheet.getPictures().add(1, 1, "example.jpeg");
//Get the inserted picture object
Picture pic = worksheet.getPictures().get(imgIndex);
//Gets the original width of the picture.
double picWidthInch = pic.getOriginalWidthInch();
//Save the excel file.
workbook.save("result.xlsx");
public SignatureLine getSignatureLine()
Example
//Instantiating a Workbook object
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.getWorksheets().get(0);
//Adding a picture at the location of a cell whose row and column indices are 1 in the worksheet. It is "B2" cell
int imgIndex = worksheet.getPictures().add(1, 1, (String)null);
//Get the inserted picture object
Picture pic = worksheet.getPictures().get(imgIndex);
// Create signature line object
SignatureLine s = new SignatureLine();
s.setSigner("Simon");
s.setTitle("Development");
s.setEmail("simon@aspose.com");
// Assign the signature line object to Picture.
pic.setSignatureLine(s);
//Save the excel file.
workbook.save("result.xlsx");
public void setSignatureLine(SignatureLine value)
public boolean isSameSetting(java.lang.Object obj)
Example
//Instantiating a Workbook object
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.getWorksheets().get(0);
//insert first picture
int imgIndex1 = worksheet.getPictures().add(1, 1, "1.png");
//Get the inserted picture object
Picture pic1 = worksheet.getPictures().get(imgIndex1);
//insert second picture
int imgIndex2 = worksheet.getPictures().add(1, 9, "2.jpeg");
//Get the inserted picture object
Picture pic2 = worksheet.getPictures().get(imgIndex2);
if(pic1.isSameSetting(pic1))
{
//two image objects are the same.
}
if(!pic1.isSameSetting(pic2))
{
//two image objects are not the same.
}
isSameSetting in class Shapeobj - 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.