Encapsulates the object that represents a single picture in a spreadsheet.
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);
Gets and sets the height scale,in unit of percent of the original picture height.
If the shape is not picture ,the HeightScale property only returns 100;
Represents the way the drawing object is attached to the cells below it.
The property controls the placement of an object on a worksheet.
The value of the property is PlacementType integer constant.
Returns a TextEffectFormat object that contains text-effect formatting properties for the specified shape.
Applies to Shape objects that represent WordArt.
Gets and sets the width scale, in unit of percent of the original picture width.
If the shape is not picture ,the WidthScale property only returns 100;
Update the selected value by the value of the linked cell.
Property Getters/Setters Detail
getOriginalHeight
public int getOriginalHeight()
Gets the original height of the 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);
//Gets the original height of the picture.
int picHeight = pic.getOriginalHeight();
//Save the excel file.
workbook.save("result.xlsx");
getOriginalWidth
public int getOriginalWidth()
Gets the original width of the 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);
//Gets the original width of the picture.
int picWidth = pic.getOriginalWidth();
//Save the excel file.
workbook.save("result.xlsx");
getBorderLineColor/setBorderLineColor
public com.aspose.cells.Color getBorderLineColor() / public void setBorderLineColor(com.aspose.cells.Color value)
Represents the com.aspose.cells.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");
getBorderWeight/setBorderWeight
public double getBorderWeight() / public void setBorderWeight(double value)
Gets or sets the weight of the border line of a picture in units of pt.
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");
getData/setData
public byte[] getData() / public void setData(byte[] value)
Gets the data of the picture.
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");
getSourceFullName/setSourceFullName
public java.lang.String getSourceFullName() / public void setSourceFullName(java.lang.String value)
Gets or sets the path and name of the source file for the linked image.
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.
getFormula/setFormula
public java.lang.String getFormula() / public void setFormula(java.lang.String value)
Gets and sets the data of the formula.
isAutoSize/setAutoSize
public boolean isAutoSize() / public 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.
isLink/setLink
public boolean isLink() / public void setLink(boolean value)
Returns true if the picture is linked to a file.
isDynamicDataExchange/setDynamicDataExchange
public boolean isDynamicDataExchange() / public void setDynamicDataExchange(boolean value)
Gets or sets whether dynamic data exchange
getDisplayAsIcon/setDisplayAsIcon
public boolean getDisplayAsIcon() / public void setDisplayAsIcon(boolean value)
True if the specified object is displayed as an icon
and the image will not be auto changed.
getImageType
public int getImageType()
Gets the image format of the picture.
The value of the property is ImageType integer constant.
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.";
}
getOriginalHeightCM
public double getOriginalHeightCM()
Gets the original height of picture, in unit of centimeters.
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");
getOriginalWidthCM
public double getOriginalWidthCM()
Gets the original width of picture, in unit of centimeters.
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");
getOriginalHeightInch
public double getOriginalHeightInch()
Gets the original height of picture, in unit of inches.
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");
getOriginalWidthInch
public double getOriginalWidthInch()
Gets the original width of picture, in unit of inches.
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");
//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);
// Create signature line object
SignatureLine s = new SignatureLine();
s.setSigner("Simon Zhao");
s.setTitle("Development Lead");
s.setEmail("Simon.Zhao@aspose.com");
// Assign the signature line object to Picture.
pic.setSignatureLine(s);
//Save the excel file.
workbook.save("result.xlsx");
Returns a MsoLineFormat object that contains line formatting properties for the specified shape.
NOTE: This member is now obsolete. Instead,
please use Shape.Line property.
This property will be removed 12 months later since July 2016.
Aspose apologizes for any inconvenience you may have experienced.
Returns a MsoFillFormat object that contains fill formatting properties for the specified shape.
NOTE: This member is now obsolete. Instead,
please use Shape.Fill property.
This property will be removed 12 months later since July 2016.
Aspose apologizes for any inconvenience you may have experienced.
Represents the setting of the shape's formatting.
NOTE: This member is now obsolete. Instead,
please use Shape.Fill and Shape.Line properties.
This property will be removed 6 months later since August 2016.
Aspose apologizes for any inconvenience you may have experienced.
Returns a TextFrame object that contains the alignment and anchoring properties for the specified shape.
NOTE: This member is now obsolete. Instead,
please use Shape.TextBody.TextAlignment property.
This property will be removed 12 months later since May 2016.
Aspose apologizes for any inconvenience you may have experienced.
Returns a TextEffectFormat object that contains text-effect formatting properties for the specified shape.
Applies to Shape objects that represent WordArt.
public int getPlacement() / public void setPlacement(int value)
Represents the way the drawing object is attached to the cells below it.
The property controls the placement of an object on a worksheet.
The value of the property is PlacementType integer constant.
Example:
if (shape.getPlacement() == PlacementType.MOVE)
shape.setPlacement(PlacementType.MOVE_AND_SIZE);
public int getTop() / public void setTop(int value)
Represents the vertical offset of shape from its top row, in unit of pixels.
If the shape is in the chart, represents the vertical offset of shape from its top border.
public int getWidthScale() / public void setWidthScale(int value)
Gets and sets the width scale, in unit of percent of the original picture width.
If the shape is not picture ,the WidthScale property only returns 100;
Example:
if (shape.getWidthScale() == 3)
shape.setWidthScale(1);
public int getHeightScale() / public void setHeightScale(int value)
Gets and sets the height scale,in unit of percent of the original picture height.
If the shape is not picture ,the HeightScale property only returns 100;
Example:
if (shape.getHeightScale() == 3)
shape.setHeightScale(1);
public int getTopInShape() / public void setTopInShape(int value)
Represents the vertical offset of shape from the top border of the parent shape,
in unit of 1/4000 of height of the parent shape.
Only Applies when this shape in the group or chart.
Example:
if (shape.getTopInShape() == 8000)
shape.setTopInShape(4000);
public int getLeftInShape() / public void setLeftInShape(int value)
Represents the horizontal offset of shape from the left border of the parent shape,
in unit of 1/4000 of width of the parent shape.
Only Applies when this shape in the group or chart.
Example:
if (shape.getUpperDeltaY() == 2000)
shape.setUpperDeltaY(4000);
public int getHeightInShape() / public void setHeightInShape(int value)
Represents the vertical offset of shape from the top border of the parent shape, in unit of 1/4000 of height of the parent shape..
Only Applies when this shape in the group or chart.
Example:
if (shape.getUpperDeltaY() == 4000)
shape.setUpperDeltaY(2000);
public int getHeightInChart() / public void setHeightInChart(int value)
Represents the vertical offset of shape from the top border of the parent shape, in unit of 1/4000 of height of the parent shape..
NOTE: This member is now obsolete. Instead,
please use Aspose.Cells.Drawing.Shape.HeightInShape property.
This property will be removed 12 months later since JANUARY 2012.
Aspose apologizes for any inconvenience you may have experienced.
public int getLeftInChart() / public void setLeftInChart(int value)
Represents the vertical offset of shape from the left border of the parent shape, in unit of 1/4000 of width of the parent shape.
NOTE: This member is now obsolete. Instead,
please use Aspose.Cells.Drawing.Shape.LeftInShape property.
This property will be removed 12 months later since JANUARY 2012.
Aspose apologizes for any inconvenience you may have experienced.
public int getTopInChart() / public void setTopInChart(int value)
Represents the vertical offset of shape from the top border of the parent shape, in unit of 1/4000 of height of the parent shape.
NOTE: This member is now obsolete. Instead,
please use Aspose.Cells.Drawing.Shape.TopInShape property.
This property will be removed 12 months later since JANUARY 2012.
Aspose apologizes for any inconvenience you may have experienced.
public int getWidthInChart() / public void setWidthInChart(int value)
Represents the width of the shape, in unit of 1/4000 of the parent shape.
NOTE: This member is now obsolete. Instead,
please use Aspose.Cells.Drawing.Shape.WidthInShape property.
This property will be removed 12 months later since JANUARY 2012.
Aspose apologizes for any inconvenience you may have experienced.
public int getPositionX() / public void setPositionX(int value)
Gets and sets the horizonal offset of shape from worksheet left border,in unit of pixels.
NOTE: This member is now obsolete. Instead,
please use Aspose.Cells.Drawing.Shape.X property.
This property will be removed 12 months later since JANUARY 2012.
Aspose apologizes for any inconvenience you may have experienced.
public int getPositionY() / public void setPositionY(int value)
Gets and sets the vertical offset of shape from worksheet top border,in unit of pixels.
NOTE: This member is now obsolete. Instead,
please use Aspose.Cells.Drawing.Shape.Y property.
This property will be removed 12 months later since JANUARY 2012.
Aspose apologizes for any inconvenience you may have experienced.
public java.awt.geom.Point2D.Float[] getConnectionPoints()
Get the connection points
NOTE: This member is now obsolete. Instead,
please use GetConnectionPoints() method.
This method will be removed 12 months later since April 2022.
Aspose apologizes for any inconvenience you may have experienced.
public int getTextVerticalOverflow() / public void setTextVerticalOverflow(int value)
Gets and sets the text vertical overflow type of the shape which contains text.
The value of the property is TextOverflowType integer constant.
Example:
if (shape.getTextVerticalOverflow() == com.aspose.cells.TextOverflowType.CLIP)
shape.setTextVerticalOverflow(com.aspose.cells.TextOverflowType.OVERFLOW);
public int getTextHorizontalOverflow() / public void setTextHorizontalOverflow(int value)
Gets and sets the text horizontal overflow type of the shape which contains text.
The value of the property is TextOverflowType integer constant.
Example:
if (shape.getTextHorizontalOverflow() == com.aspose.cells.TextOverflowType.CLIP)
shape.setTextHorizontalOverflow(com.aspose.cells.TextOverflowType.OVERFLOW);
public int getTextOrientationType() / public void setTextOrientationType(int value)
Gets and sets the text orientation type of the shape.
The value of the property is TextOrientationType integer constant.
Example:
if (shape.getTextOrientationType() == com.aspose.cells.TextOrientationType.NO_ROTATION)
shape.setTextOrientationType(com.aspose.cells.TextOrientationType.TOP_TO_BOTTOM);
public int getTextHorizontalAlignment() / public void setTextHorizontalAlignment(int value)
Gets and sets the text horizontal alignment type of the shape.
The value of the property is TextAlignmentType integer constant.
Example:
if (shape.getTextHorizontalAlignment() == com.aspose.cells.TextAlignmentType.BOTTOM)
shape.setTextHorizontalAlignment(com.aspose.cells.TextAlignmentType.CENTER);
public int getTextVerticalAlignment() / public void setTextVerticalAlignment(int value)
Gets and sets the text vertical alignment type of the shape.
The value of the property is TextAlignmentType integer constant.
Example:
if (shape.getTextVerticalAlignment() == com.aspose.cells.TextAlignmentType.BOTTOM)
shape.setTextVerticalAlignment(com.aspose.cells.TextAlignmentType.CENTER);
CheckBoxActiveXControl checkBox1 = (CheckBoxActiveXControl)shape.getActiveXControl();
//The font name of CheckBox
String fontName = checkBox1.getFont().getName();
public void copy(Picture source, CopyOptions options)
throws java.lang.Exception
Copy the picture.
Parameters:
source - The source picture.
options - The copy 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");
move
public void move(int upperLeftRow, int upperLeftColumn)
Moves the picture to a specified location.
Parameters:
upperLeftRow - Upper left row index.
upperLeftColumn - Upper left column index.
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");
isSameSetting
public boolean isSameSetting(java.lang.Object obj)
Returns whether the shape is same.
Parameters:
obj -
Returns:
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.
}
public void setLinkedCell(java.lang.String formula, boolean isR1C1, boolean isLocal)
Sets the range linked to the control's value.
Parameters:
formula - The range linked to the control's value.
isR1C1 - Whether the formula needs to be formatted as R1C1.
isLocal - Whether the formula needs to be formatted by locale.
Example:
//After executing the code below, a ScrollBar object is created in the generated file. As you drag the slider, the value is displayed in cell A12.
//ActiveX Controls
//Aspose.Cells.Drawing.Shape scrollBar = book.Worksheets[0].Shapes.AddActiveXControl( Aspose.Cells.Drawing.ActiveXControls.ControlType.ScrollBar,2, 0, 2, 0, 30, 130);
//Form Controls
Shape scrollBar = book.getWorksheets().get(0).getShapes().addScrollBar(2, 0, 2, 0, 130, 30);
//Sets the range linked to the control's value.
scrollBar.setLinkedCell("$A$12", false, true);
public void setInputRange(java.lang.String formula, boolean isR1C1, boolean isLocal)
Sets the range used to fill the control.
Parameters:
formula - The range used to fill the control.
isR1C1 - Whether the formula needs to be formatted as R1C1.
isLocal - Whether the formula needs to be formatted by locale.
Example:
//After executing the code below, a ListBox object is created in the generated file. When the selected option is clicked, the selected value is displayed in cell A12.
//Initialize a new workbook.
//Workbook book = new Workbook();
for (int i = 0; i< 10; ++i)
{
Cell cell = book.getWorksheets().get(0).getCells().get(i, 0);
cell.setValue(i + 1);
}
//Create a ListBox object
//ActiveX Controls
//Aspose.Cells.Drawing.Shape listBox = book.Worksheets[0].Shapes.AddActiveXControl( Aspose.Cells.Drawing.ActiveXControls.ControlType.ListBox,2, 0, 2, 0, 130, 130);
//Form Controls
Shape listBox = book.getWorksheets().get(0).getShapes().addListBox(2, 0, 2, 0, 130, 130);
//Sets the range used to fill the control.
listBox.setInputRange("$A$1:$A$6", false, false);
//Sets the range linked to the control's value.
listBox.setLinkedCell("$A$12", false, true);
public void updateSelectedValue()
throws java.lang.Exception
Update the selected value by the value of the linked cell.
Example:
//Initialize a new workbook.
//Workbook book = new Workbook();
Cell cell = null;
for (int i = 0; i< 10; ++i)
{
cell = book.getWorksheets().get(0).getCells().get(i, 0);
cell.setValue(i + 1);
}
//Create a ListBox object
//ActiveX Controls
//Aspose.Cells.Drawing.Shape listBox = book.Worksheets[0].Shapes.AddActiveXControl( Aspose.Cells.Drawing.ActiveXControls.ControlType.ListBox,2, 0, 2, 0, 130, 130);
//Form Controls
Shape listBox = book.getWorksheets().get(0).getShapes().addListBox(2, 0, 2, 0, 130, 130);
//Sets the range used to fill the control.
listBox.setInputRange("$A$1:$A$6", false, false);
//Sets the range linked to the control's value.
listBox.setLinkedCell("$A$12", false, true);
ListBox listbx = (ListBox)listBox;
//Set the value of cell A12
cell = book.getWorksheets().get(0).getCells().get(11, 0);
cell.setValue(3);
//Update the selected value by the value of the linked cell.
listBox.updateSelectedValue();
//-1 default, no option selected
if(listbx.isSelected(2))
{
//Option 3 of the ListBox is selected
}
//Change the value of a linked cell
cell.setValue(4);
//Update the selected value by the value of the linked cell.
listBox.updateSelectedValue();
if(listbx.isSelected(3))
{
//Option 4 of the ListBox is selected
}
public void formatCharacters(int startIndex, int length, Font font)
Formats some characters with the font setting.
NOTE: This member is now obsolete. Instead,
please use Shape.FormatCharacters(int startIndex, int length, Font font, StyleFlag flag) method.
This property will be removed 12 months later since March 2016.
Aspose apologizes for any inconvenience you may have experienced.