public class Shape
extends java.lang.Object
Example
//Initialize a new workbook.
Workbook book = new Workbook();
//Add a shape.(e.g rectangle)
Shape shape = book.getWorksheets().get(0).getShapes().addRectangle(2, 0, 2, 0, 130, 130);
//do your business
//Save the excel file.
book.save("exmaple.xlsx");
| Modifier and Type | Method and Description |
|---|---|
Hyperlink |
addHyperlink(java.lang.String address)
Adds a hyperlink to the shape.
|
void |
alignTopRightCorner(int topRow,
int rightColumn)
Moves the picture to the top-right corner.
|
int[] |
calculateTextSize()
Recalculate the text area
|
FontSetting |
characters(int startIndex,
int length)
Returns a Characters object that represents a range of characters within the text.
|
void |
fitToTextSize()
Recalculate a text area suitable for displaying all text content.
|
void |
formatCharacters(int startIndex,
int length,
Font font,
StyleFlag flag)
Formats some characters with the font setting.
|
ActiveXControl |
getActiveXControl()
Gets the ActiveX control.
|
float[] |
getActualBox()
Get the actual position and size of the shape (after applying rotation, flip, etc.)
|
int |
getActualLowerRightRow()
Get the actual bottom row.
|
java.lang.String |
getAlternativeText()
Returns or sets the descriptive (alternative) text string of the
Shape object. |
int |
getAnchorType()
Gets the type of the shape anchor placeholder.
|
int |
getAutoShapeType()
Gets the auto shape type.
|
int |
getBottom()
Represents the width of the shape's vertical offset from its lower bottom corner row, in unit of pixels.
|
java.util.ArrayList |
getCharacters()
Deprecated.
Use Shape.GetRichFormattings() instead.
|
float[][] |
getConnectionPoints()
Get the connection points
|
byte[] |
getControlData()
Gets the data of control.
|
java.util.UUID |
getCreateId()
Gets create id for this shape.
|
FillFormat |
getFill()
Returns a
Area.getFillFormat() object that contains fill formatting properties for the specified shape. |
MsoFillFormat |
getFillFormat()
Deprecated.
Use Shape.Fill property instead.
|
Font |
getFont()
Represents the font of shape.
|
MsoFormatPicture |
getFormatPicture()
Gets the options of the picture format.
|
Geometry |
getGeometry()
Gets the geometry
|
GlowEffect |
getGlow()
Represents a
ShapePropertyCollection.getGlowEffect() object that specifies glow effect for the chart element or shape. |
GroupShape |
getGroup()
Gets the group shape which contains this shape.
|
int |
getHeight()
Represents the height of shape, in unit of pixel.
|
double |
getHeightCM()
Represents the height of the shape, in unit of centimeters.
|
double |
getHeightInch()
Represents the height of the shape, in unit of inches.
|
int |
getHeightInShape()
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..
|
double |
getHeightPt()
Represents the height of the shape, in unit of points.
|
int |
getHeightScale()
Gets the height scale,in unit of percent of the original picture height.
|
java.lang.String |
getHtmlText()
Gets the html string which contains data and some formats in this textbox.
|
Hyperlink |
getHyperlink()
Gets the hyperlink of the shape.
|
int |
getId()
Gets the identifier of this shape.
|
java.lang.String |
getInputRange()
Gets the worksheet range used to fill the specified combo box.
|
java.lang.String |
getInputRange(boolean isR1C1,
boolean isLocal)
Gets the range used to fill the control.
|
int |
getLeft()
Represents the horizontal offset of shape from its left column, in unit of pixels.
|
double |
getLeftCM()
Represents the horizontal offset of shape from its left column, in unit of centimeters.
|
double |
getLeftInch()
Represents the horizontal offset of shape from its left column, in unit of inches.
|
int |
getLeftInShape()
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.
|
int |
getLeftToCorner()
Gets the horizonal offset of shape from worksheet left border.
|
LineFormat |
getLine()
Gets line style
|
MsoLineFormat |
getLineFormat()
Deprecated.
Use Shape.Line property instead.
|
java.lang.String |
getLinkedCell()
Gets the worksheet range linked to the control's value.
|
java.lang.String |
getLinkedCell(boolean isR1C1,
boolean isLocal)
Gets the range linked to the control's value.
|
boolean |
getLockedProperty(int type)
Gets the value of locked property.
|
int |
getLowerDeltaX()
Gets the shape's horizontal offset from its lower right corner column.
|
int |
getLowerDeltaY()
Gets the shape's vertical offset from its lower right corner row.
|
int |
getLowerRightColumn()
Represents lower right corner column index.
|
int |
getLowerRightRow()
Represents lower right corner row index.
|
java.lang.String |
getMacroName()
Gets the name of macro.
|
int |
getMsoDrawingType()
Gets drawing type.
|
java.lang.String |
getName()
Gets the name of the shape.
|
ShapePathCollection |
getPaths()
Gets the paths of a custom geometric shape.
|
int |
getPlacement()
Represents the way the drawing object is attached to the cells below it.
|
ReflectionEffect |
getReflection()
Represents a
ReflectionEffect object that specifies reflection effect for the chart element or shape. |
boolean |
getRelativeToOriginalPictureSize()
Indicates whether shape is relative to original picture size.
|
GroupShape |
getResultOfSmartArt()
Converting smart art to grouped shapes.
|
FontSetting[] |
getRichFormattings()
Returns all Characters objects
that represents a range of characters within the text .
|
int |
getRight()
Represents the width of the shape's horizontal offset from its lower right corner column, in unit of pixels.
|
double |
getRotationAngle()
Gets the rotation of the shape.
|
ShadowEffect |
getShadowEffect()
Represents a
ShadowEffect object that specifies shadow effect for the chart element or shape. |
double |
getSoftEdges()
Gets the radius of blur to apply to the edges, in unit of points.
|
java.lang.String |
getSpid()
Specifies an optional string identifier that an application can use to identify the particular shape.
|
int |
getSpt()
Specifies an optional number that an application can use to associate the particular shape with a defined shape type.
|
java.lang.String |
getText()
Gets the text of this shape.
|
FontSettingCollection |
getTextBody()
Gets the setting of the shape's text.
|
TextBoxOptions |
getTextBoxOptions()
Gets the text information in the shape
|
int |
getTextDirection()
Gets the direction of the text flow for this object.
|
TextEffectFormat |
getTextEffect()
Returns a TextEffectFormat object that contains text-effect formatting properties for the specified shape.
|
int |
getTextHorizontalAlignment()
Gets the text horizontal alignment type of the shape.
|
int |
getTextHorizontalOverflow()
Gets the text horizontal overflow type of the shape which contains text.
|
TextOptions |
getTextOptions()
Represents the text options of the shape.
|
int |
getTextOrientationType()
Gets the text orientation type of the shape.
|
int |
getTextShapeType()
Gets the preset text shape type.
|
int |
getTextVerticalAlignment()
Gets the text vertical alignment type of the shape.
|
int |
getTextVerticalOverflow()
Gets the text vertical overflow type of the shape which contains text.
|
ThreeDFormat |
getThreeDFormat()
Gets 3d format of the shape.
|
java.lang.String |
getTitle()
Specifies the title (caption) of the current shape object.
|
int |
getTop()
Represents the vertical offset of shape from its top row, in unit of pixels.
|
double |
getTopCM()
Represents the vertical offset of shape from its top row, in unit of centimeters.
|
double |
getTopInch()
Represents the vertical offset of shape from its top row, in unit of inches.
|
int |
getTopInShape()
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.
|
int |
getTopToCorner()
Gets the vertical offset of shape from worksheet top border, in unit of pixels.
|
int |
getType()
Gets the auto shape type.
|
int |
getUpperDeltaX()
Gets the shape's horizontal offset from its upper left corner column.
|
int |
getUpperDeltaY()
Gets the shape's vertical offset from its upper left corner row.
|
int |
getUpperLeftColumn()
Represents upper left corner column index.
|
int |
getUpperLeftRow()
Represents the top row index.
|
int |
getWidth()
Represents the width of shape, in unit of pixels.
|
double |
getWidthCM()
Represents the width of the shape, in unit of centimeters.
|
double |
getWidthInch()
Represents the width of the shape, in unit of inch.
|
int |
getWidthInShape()
Represents the width of the shape, in unit of 1/4000 of the parent shape.
|
double |
getWidthPt()
Represents the width of the shape, in unit of point.
|
int |
getWidthScale()
Gets the width scale, in unit of percent of the original picture width.
|
Worksheet |
getWorksheet()
Gets the
Range.getWorksheet() object which contains this shape. |
int |
getX()
Gets the horizontal offset of shape from worksheet left border,in unit of pixels.
|
int |
getY()
Gets the vertical offset of shape from worksheet top border,in unit of pixels.
|
int |
getZOrderPosition()
Returns the position of a shape in the z-order.
|
boolean |
hasLine()
Gets the line border of the shape is visible.
|
boolean |
isAspectRatioLocked()
True means that aspect ratio of the shape is locked.
|
boolean |
isDecorative()
Indicates whether the object is decorative.
|
boolean |
isEquation()
Indicates whether the shape only contains an equation.
|
boolean |
isFilled()
Indicates whether the fill format is visible.
|
boolean |
isFlippedHorizontally()
Gets whether shape is horizontally flipped .
|
boolean |
isFlippedVertically()
Gets whether shape is vertically flipped .
|
boolean |
isGroup()
Indicates whether this shape is a group shape.
|
boolean |
isHidden()
Indicates whether the object is visible.
|
boolean |
isInGroup()
Indicates whether the shape is grouped.
|
boolean |
isLockAspectRatio()
Deprecated.
Use Shape.IsAspectRatioLocked property instead.
|
boolean |
isLocked()
True means the object can not be modified when the sheet is protected.
|
boolean |
isPrintable()
Indicates whether the object is printable.
|
boolean |
isRichText()
Whether or not the text is rich text.
|
boolean |
isSameSetting(java.lang.Object obj)
Returns whether the shape is same.
|
boolean |
isSmartArt()
Indicates whether the shape is a smart art.
|
boolean |
isTextWrapped()
Gets the text wrapped type of the shape which contains text.
|
boolean |
isWordArt()
Indicates whether this shape is a word art.
|
void |
moveToRange(int upperLeftRow,
int upperLeftColumn,
int lowerRightRow,
int lowerRightColumn)
Moves the shape to a specified range.
|
void |
removeActiveXControl()
Remove activeX control.
|
void |
removeHyperlink()
Removes the hyperlink of the shape.
|
void |
setAlternativeText(java.lang.String value)
Returns or sets the descriptive (alternative) text string of the
Shape object. |
void |
setAnchorType(int value)
Sets the type of the shape anchor placeholder.
|
void |
setAspectRatioLocked(boolean value)
True means that aspect ratio of the shape is locked.
|
void |
setAutoShapeType(int value)
Sets the auto shape type.
|
void |
setBottom(int value)
Represents the width of the shape's vertical offset from its lower bottom corner row, in unit of pixels.
|
void |
setCreateId(java.util.UUID value)
Sets create id for this shape.
|
void |
setDecorative(boolean value)
Indicates whether the object is decorative.
|
void |
setFilled(boolean value)
Indicates whether the fill format is visible.
|
void |
setFlippedHorizontally(boolean value)
Sets whether shape is horizontally flipped .
|
void |
setFlippedVertically(boolean value)
Sets whether shape is vertically flipped .
|
void |
setFont(Font value)
Represents the font of shape.
|
void |
setHasLine(boolean value)
Sets the line border of the shape is visible.
|
void |
setHeight(int value)
Represents the height of shape, in unit of pixel.
|
void |
setHeightCM(double value)
Represents the height of the shape, in unit of centimeters.
|
void |
setHeightInch(double value)
Represents the height of the shape, in unit of inches.
|
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..
|
void |
setHeightPt(double value)
Represents the height of the shape, in unit of points.
|
void |
setHeightScale(int value)
Sets the height scale,in unit of percent of the original picture height.
|
void |
setHidden(boolean value)
Indicates whether the object is visible.
|
void |
setHtmlText(java.lang.String value)
Sets the html string which contains data and some formats in this textbox.
|
void |
setInputRange(java.lang.String value)
Sets the worksheet range used to fill the specified combo box.
|
void |
setInputRange(java.lang.String formula,
boolean isR1C1,
boolean isLocal)
Sets the range used to fill the control.
|
void |
setLeft(int value)
Represents the horizontal offset of shape from its left column, in unit of pixels.
|
void |
setLeftCM(double value)
Represents the horizontal offset of shape from its left column, in unit of centimeters.
|
void |
setLeftInch(double value)
Represents the horizontal offset of shape from its left column, in unit of inches.
|
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.
|
void |
setLeftToCorner(int value)
Sets the horizonal offset of shape from worksheet left border.
|
void |
setLinkedCell(java.lang.String value)
Sets the worksheet range linked to the control's value.
|
void |
setLinkedCell(java.lang.String formula,
boolean isR1C1,
boolean isLocal)
Sets the range linked to the control's value.
|
void |
setLockAspectRatio(boolean value)
Deprecated.
Use Shape.IsAspectRatioLocked property instead.
|
void |
setLocked(boolean value)
True means the object can not be modified when the sheet is protected.
|
void |
setLockedProperty(int type,
boolean value)
Set the locked property.
|
void |
setLowerDeltaX(int value)
Sets the shape's horizontal offset from its lower right corner column.
|
void |
setLowerDeltaY(int value)
Sets the shape's vertical offset from its lower right corner row.
|
void |
setLowerRightColumn(int value)
Represents lower right corner column index.
|
void |
setLowerRightRow(int value)
Represents lower right corner row index.
|
void |
setMacroName(java.lang.String value)
Sets the name of macro.
|
void |
setName(java.lang.String value)
Sets the name of the shape.
|
void |
setPlacement(int value)
Represents the way the drawing object is attached to the cells below it.
|
void |
setPrintable(boolean value)
Indicates whether the object is printable.
|
void |
setRelativeToOriginalPictureSize(boolean value)
Indicates whether shape is relative to original picture size.
|
void |
setRight(int value)
Represents the width of the shape's horizontal offset from its lower right corner column, in unit of pixels.
|
void |
setRotationAngle(double value)
Sets the rotation of the shape.
|
void |
setSoftEdges(double value)
Sets the radius of blur to apply to the edges, in unit of points.
|
void |
setText(java.lang.String value)
Sets the text of this shape.
|
void |
setTextDirection(int value)
Sets the direction of the text flow for this object.
|
void |
setTextHorizontalAlignment(int value)
Sets the text horizontal alignment type of the shape.
|
void |
setTextHorizontalOverflow(int value)
Sets the text horizontal overflow type of the shape which contains text.
|
void |
setTextOptions(TextOptions value)
Represents the text options of the shape.
|
void |
setTextOrientationType(int value)
Sets the text orientation type of the shape.
|
void |
setTextShapeType(int value)
Sets the preset text shape type.
|
void |
setTextVerticalAlignment(int value)
Sets the text vertical alignment type of the shape.
|
void |
setTextVerticalOverflow(int value)
Sets the text vertical overflow type of the shape which contains text.
|
void |
setTextWrapped(boolean value)
Sets the text wrapped type of the shape which contains text.
|
void |
setTitle(java.lang.String value)
Specifies the title (caption) of the current shape object.
|
void |
setTop(int value)
Represents the vertical offset of shape from its top row, in unit of pixels.
|
void |
setTopCM(double value)
Represents the vertical offset of shape from its top row, in unit of centimeters.
|
void |
setTopInch(double value)
Represents the vertical offset of shape from its top row, in unit of inches.
|
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.
|
void |
setTopToCorner(int value)
Sets the vertical offset of shape from worksheet top border, in unit of pixels.
|
void |
setUpperDeltaX(int value)
Sets the shape's horizontal offset from its upper left corner column.
|
void |
setUpperDeltaY(int value)
Sets the shape's vertical offset from its upper left corner row.
|
void |
setUpperLeftColumn(int value)
Represents upper left corner column index.
|
void |
setUpperLeftRow(int value)
Represents the top row index.
|
void |
setWidth(int value)
Represents the width of shape, in unit of pixels.
|
void |
setWidthCM(double value)
Represents the width of the shape, in unit of centimeters.
|
void |
setWidthInch(double value)
Represents the width of the shape, in unit of inch.
|
void |
setWidthInShape(int value)
Represents the width of the shape, in unit of 1/4000 of the parent shape.
|
void |
setWidthPt(double value)
Represents the width of the shape, in unit of point.
|
void |
setWidthScale(int value)
Sets the width scale, in unit of percent of the original picture width.
|
void |
setX(int value)
Sets the horizontal offset of shape from worksheet left border,in unit of pixels.
|
void |
setY(int value)
Sets the vertical offset of shape from worksheet top border,in unit of pixels.
|
void |
setZOrderPosition(int value)
Returns the position of a shape in the z-order.
|
void |
toFrontOrBack(int orders)
Brings the shape to the front or sends the shape to back.
|
void |
toImage(java.io.OutputStream stream,
ImageFormat imageFormat)
Creates the shape image and saves it to a stream in the specified format.
|
void |
toImage(java.io.OutputStream stream,
ImageOrPrintOptions options)
Saves the shape to a stream.
|
void |
toImage(java.lang.String imageFile,
ImageOrPrintOptions options)
Saves the shape to a file.
|
void |
updateSelectedValue()
Update the selected value by the value of the linked cell.
|
public java.lang.String getMacroName()
Example
//Sets the name of macro.
shape.setMacroName("DoWork()");
public void setMacroName(java.lang.String value)
public boolean isEquation()
Example
//If true,the shape only contains an equation.
if(shape.isEquation())
{
//The shape contains only an equation
}
public boolean isSmartArt()
Remarks
Only for ooxml file.Example
//if true,the shape is a smart art.
if(shape.isSmartArt())
{
//The shape is SmartArt object.
}
public GroupShape getResultOfSmartArt()
Example
if(shape.isSmartArt())
{
GroupShape groupShape = shape.getResultOfSmartArt();
}
public void toFrontOrBack(int orders)
Example
shape.toFrontOrBack(2);
//or shape.ToFrontOrBack(-1);
orders - If it's less than zero, sets the shape to back.
If it's greater than zero, brings the shape to front.public int getZOrderPosition()
Example
shape.setZOrderPosition(3);
public void setZOrderPosition(int value)
public java.lang.String getName()
Example
shape.setName("shape1");
public void setName(java.lang.String value)
public java.lang.String getAlternativeText()
Shape object.
Example
shape.setAlternativeText("a rectangle");
public void setAlternativeText(java.lang.String value)
Shape object.public java.lang.String getTitle()
Example
shape.setTitle("title1");
public void setTitle(java.lang.String value)
public MsoLineFormat getLineFormat()
Remarks
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.public MsoFillFormat getFillFormat()
Remarks
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.public LineFormat getLine()
Example
LineFormat lineFmt = shape.getLine();
public FillFormat getFill()
Area.getFillFormat() object that contains fill formatting properties for the specified shape.
Example
FillFormat fillFmt = shape.getFill();
public ShadowEffect getShadowEffect()
ShadowEffect object that specifies shadow effect for the chart element or shape.
Example
ShadowEffect shadowEffect = shape.getShadowEffect();
public ReflectionEffect getReflection()
ReflectionEffect object that specifies reflection effect for the chart element or shape.
Example
ReflectionEffect reflectionEffect = shape.getReflection();
public GlowEffect getGlow()
ShapePropertyCollection.getGlowEffect() object that specifies glow effect for the chart element or shape.
Example
GlowEffect glowEffect = shape.getGlow();
public double getSoftEdges()
Example
shape.setSoftEdges(0.5d);
public void setSoftEdges(double value)
public ThreeDFormat getThreeDFormat()
Example
ThreeDFormat threeDFormat = shape.getThreeDFormat();
public MsoFormatPicture getFormatPicture()
Example
MsoFormatPicture msoFormatPicture = shape.getFormatPicture();
public boolean isHidden()
Example
shape.setHidden(false);
public void setHidden(boolean value)
public boolean isLockAspectRatio()
Remarks
Only for pictures and Ole Objects. NOTE: This member is now obsolete. Instead, please use Shape.IsAspectRatioLocked property. This property will be removed 12 months later since July 2024. Aspose apologizes for any inconvenience you may have experienced.Example
shape.setHidden(false);
public void setLockAspectRatio(boolean value)
Remarks
Only for pictures and Ole Objects. NOTE: This member is now obsolete. Instead, please use Shape.IsAspectRatioLocked property. This property will be removed 12 months later since July 2024. Aspose apologizes for any inconvenience you may have experienced.public boolean isAspectRatioLocked()
Remarks
Only for pictures and Ole Objects.Example
shape.setAspectRatioLocked(false);
public void setAspectRatioLocked(boolean value)
Remarks
Only for pictures and Ole Objects.public boolean getLockedProperty(int type)
Example
int noAdjustHandles = 0;
if (shape.getLockedProperty(ShapeLockType.ADJUST_HANDLES))
noAdjustHandles = 1;
type - ShapeLockType. The type of the shape locked property.public void setLockedProperty(int type,
boolean value)
Example
shape.setLockedProperty(ShapeLockType.ADJUST_HANDLES, true);
type - ShapeLockType. The locked type.value - The value of the property.public double getRotationAngle()
Example
//Gets rotation angle of the shape.
double angle = shape.getRotationAngle() ;
//Gets rotation angle of the shape.
shape.setRotationAngle(60);
public void setRotationAngle(double value)
public Hyperlink addHyperlink(java.lang.String address)
Example
Hyperlink hyperlink = shape.addHyperlink("https://www.aspose.com/");
address - Address of the hyperlink.public void removeHyperlink()
Example
shape.removeHyperlink();
public Hyperlink getHyperlink()
Example
Hyperlink hyperlink = shape.getHyperlink();
public void moveToRange(int upperLeftRow,
int upperLeftColumn,
int lowerRightRow,
int lowerRightColumn)
Example
shape.moveToRange(12, 3, 13, 5);
upperLeftRow - Upper left row index.upperLeftColumn - Upper left column index.lowerRightRow - Lower right row indexlowerRightColumn - Lower right column indexpublic void alignTopRightCorner(int topRow,
int rightColumn)
Example
shape.alignTopRightCorner(2, 5);
topRow - the row index.rightColumn - the column index.public int getId()
Example
int id = shape.getId();
public java.lang.String getSpid()
Example
String spid = shape.getSpid();
public int getSpt()
Example
int spt = shape.getSpt();
public Worksheet getWorksheet()
Range.getWorksheet() object which contains this shape.
Example
Worksheet worksheet = shape.getWorksheet();
public boolean isGroup()
Example
if(shape.isGroup())
{
//This shape is a group.
}
public boolean isInGroup()
public boolean isWordArt()
Remarks
Only for the Legacy Shape of xls file.Example
if(shape.isWordArt())
{
//This shape is a WordArt object.
}
public TextEffectFormat getTextEffect()
Example
if(shape.isWordArt())
{
TextEffectFormat textEffectFormat = shape.getTextEffect();
}
public boolean isLocked()
Example
//Sets the specified shape to unlocked state
if (shape.getWorksheet().isProtected() &&shape.isLocked())
{
shape.setLocked(false);
}
//Sets the specified shape to a locked state
if (shape.getWorksheet().isProtected() &&!shape.isLocked())
{
shape.setLocked(true);
}
public void setLocked(boolean value)
public boolean isPrintable()
Example
if(shape.isPrintable())
shape.setPrintable(false);
public void setPrintable(boolean value)
public int getMsoDrawingType()
See MsoDrawingType.
Example
/*Aspose.Cells.Drawing.MsoDrawingType*/int msoDrawingType = shape.getMsoDrawingType();
public int getAutoShapeType()
See AutoShapeType.
Example
if (shape.getAutoShapeType() == com.aspose.cells.AutoShapeType.UNKNOWN)
shape.setAutoShapeType(com.aspose.cells.AutoShapeType.RECTANGLE);
public void setAutoShapeType(int value)
See AutoShapeType.
public int getAnchorType()
See ShapeAnchorType.
Example
if (shape.getAnchorType() == ShapeAnchorType.ONE_CELL_ANCHOR)
shape.setAnchorType(ShapeAnchorType.TWO_CELL_ANCHOR);
public void setAnchorType(int value)
See ShapeAnchorType.
public int getPlacement()
See PlacementType.
Example
if (shape.getPlacement() == PlacementType.MOVE)
shape.setPlacement(PlacementType.MOVE_AND_SIZE);
public void setPlacement(int value)
See PlacementType.
public int getUpperLeftRow()
Remarks
If the shape is in the shape or in the group , UpperLeftRow will be ignored.Example
if (shape.getUpperLeftRow() == 3)
shape.setUpperLeftRow(1);
public void setUpperLeftRow(int value)
Remarks
If the shape is in the shape or in the group , UpperLeftRow will be ignored.public int getUpperDeltaY()
Remarks
The range of value is 0 to 256.Example
if (shape.getUpperDeltaY() == 3)
shape.setUpperDeltaY(1);
public void setUpperDeltaY(int value)
Remarks
The range of value is 0 to 256.public int getUpperLeftColumn()
Example
if (shape.getUpperLeftColumn() == 3)
shape.setUpperLeftColumn(1);
public void setUpperLeftColumn(int value)
public int getUpperDeltaX()
Remarks
The range of value is 0 to 1024.Example
if (shape.getUpperDeltaX() == 3)
shape.setUpperDeltaX(1);
public void setUpperDeltaX(int value)
Remarks
The range of value is 0 to 1024.public int getLowerRightRow()
Example
if (shape.getLowerRightRow() == 3)
shape.setLowerRightRow(1);
public void setLowerRightRow(int value)
public int getLowerDeltaY()
Remarks
The range of value is 0 to 256.Example
if (shape.getLowerDeltaY() == 3)
shape.setLowerDeltaY(1);
public void setLowerDeltaY(int value)
Remarks
The range of value is 0 to 256.public int getLowerRightColumn()
Example
if (shape.getLowerRightColumn() == 3)
shape.setLowerRightColumn(1);
public void setLowerRightColumn(int value)
public int getLowerDeltaX()
Remarks
The range of value is 0 to 1024.Example
if (shape.getLowerDeltaX() == 3)
shape.setLowerDeltaX(1);
public void setLowerDeltaX(int value)
Remarks
The range of value is 0 to 1024.public int getRight()
Example
if (shape.getRight() == 3)
shape.setRight(1);
public void setRight(int value)
public int getBottom()
Example
if (shape.getBottom() == 3)
shape.setBottom(1);
public void setBottom(int value)
public int getWidth()
Example
if (shape.getWidth() == 3)
shape.setWidth(1);
public void setWidth(int value)
public double getWidthInch()
Example
if (shape.getWidthInch() == 3)
shape.setWidthInch(1);
public void setWidthInch(double value)
public double getWidthPt()
Example
if (shape.getWidthPt() == 3)
shape.setWidthPt(1);
public void setWidthPt(double value)
public double getWidthCM()
Example
if (shape.getWidthCM() == 3)
shape.setWidthCM(1);
public void setWidthCM(double value)
public int getHeight()
Example
if (shape.getHeight() == 3)
shape.setHeight(1);
public void setHeight(int value)
public double getHeightInch()
Example
if (shape.getHeightInch() == 3)
shape.setHeightInch(1);
public void setHeightInch(double value)
public double getHeightPt()
Example
if (shape.getHeightPt() == 3)
shape.setHeightPt(1);
public void setHeightPt(double value)
public double getHeightCM()
Example
if (shape.getHeightCM() == 3)
shape.setHeightCM(1);
public void setHeightCM(double value)
public int getLeft()
Example
if (shape.getLeft() == 3)
shape.setLeft(1);
public void setLeft(int value)
public double getLeftInch()
Example
if (shape.getLeftInch() == 3)
shape.setLeftInch(1);
public void setLeftInch(double value)
public double getLeftCM()
Example
if (shape.getLeftCM() == 3)
shape.setLeftCM(1);
public void setLeftCM(double value)
public int getTop()
Remarks
If the shape is in the chart, represents the vertical offset of shape from its top border.Example
if (shape.getTop() == 3)
shape.setTop(1);
public void setTop(int value)
Remarks
If the shape is in the chart, represents the vertical offset of shape from its top border.public double getTopInch()
Example
if (shape.getTopInch() == 3)
shape.setTopInch(1);
public void setTopInch(double value)
public double getTopCM()
Example
if (shape.getTopCM() == 3)
shape.setTopCM(1);
public void setTopCM(double value)
public int getTopToCorner()
Example
if (shape.getTopToCorner() == 3)
shape.setTopToCorner(1);
public void setTopToCorner(int value)
public int getLeftToCorner()
Example
if (shape.getLeftToCorner() == 3)
shape.setLeftToCorner(1);
public void setLeftToCorner(int value)
public int getX()
Example
if (shape.getX() == 3)
shape.setX(1);
public void setX(int value)
public int getY()
Example
if (shape.getY() == 3)
shape.setY(1);
public void setY(int value)
public int getWidthScale()
Example
if (shape.getWidthScale() == 3)
shape.setWidthScale(1);
public void setWidthScale(int value)
public int getHeightScale()
Example
if (shape.getHeightScale() == 3)
shape.setHeightScale(1);
public void setHeightScale(int value)
public int getTopInShape()
Remarks
Only Applies when this shape in the group or chart.Example
if (shape.isInGroup() &&shape.getTopInShape() == 8000)
shape.setTopInShape(4000);
public void setTopInShape(int value)
Remarks
Only Applies when this shape in the group or chart.public int getLeftInShape()
Remarks
Only Applies when this shape in the group or chart.Example
if (shape.isInGroup() &&shape.getLeftInShape() == 2000)
shape.setLeftInShape(4000);
public void setLeftInShape(int value)
Remarks
Only Applies when this shape in the group or chart.public int getWidthInShape()
Remarks
Only Applies when this shape in the group or chart.Example
if (shape.isInGroup() &&shape.getWidthInShape() == 2000)
shape.setWidthInShape(4000);
public void setWidthInShape(int value)
Remarks
Only Applies when this shape in the group or chart.public int getHeightInShape()
Remarks
Only Applies when this shape in the group or chart.Example
if (shape.isInGroup() &&shape.getHeightInShape() == 4000)
shape.setHeightInShape(2000);
public void setHeightInShape(int value)
Remarks
Only Applies when this shape in the group or chart.public GroupShape getGroup()
Example
GroupShape groupShape = shape.getGroup();
public int getType()
See AutoShapeType.
Example
/*Aspose.Cells.Drawing.AutoShapeType*/int autoShapeType = shape.getType();
public boolean hasLine()
Example
if(shape.hasLine() == false)
shape.setHasLine(true);
public void setHasLine(boolean value)
public boolean isFilled()
Example
if(shape.isFilled() == false)
shape.setFilled(true);
public void setFilled(boolean value)
public boolean isFlippedHorizontally()
Example
if(shape.isFlippedHorizontally() == false)
shape.setFlippedHorizontally(true);
public void setFlippedHorizontally(boolean value)
public boolean isFlippedVertically()
Example
if(shape.isFlippedVertically() == false)
shape.setFlippedVertically(true);
public void setFlippedVertically(boolean value)
public int getActualLowerRightRow()
Example
int rRow = shape.getActualLowerRightRow();
public float[][] getConnectionPoints()
Example
float[][] points = shape.getConnectionPoints();
public void toImage(java.io.OutputStream stream,
ImageFormat imageFormat)
Remarks
The following formats are supported: .bmp, .gif, .jpg, .jpeg, .tiff, .emf.
stream - The output stream.imageFormat - The format in which to save the image.public void toImage(java.lang.String imageFile,
ImageOrPrintOptions options)
Example
ImageOrPrintOptions op = new ImageOrPrintOptions();
shape.toImage("exmaple.png", op);
public void toImage(java.io.OutputStream stream,
ImageOrPrintOptions options)
public boolean getRelativeToOriginalPictureSize()
Example
if(shape.getRelativeToOriginalPictureSize())
shape.setRelativeToOriginalPictureSize(false);
public void setRelativeToOriginalPictureSize(boolean value)
public java.lang.String getLinkedCell()
Example
if (shape.getLinkedCell().equals("$B$6"))
shape.setLinkedCell("A1");
shape.updateSelectedValue();
public void setLinkedCell(java.lang.String value)
public java.lang.String getInputRange()
Example
if (shape.getInputRange().equals("$B$6:$B10"))
shape.setInputRange("$A$1:$A$5");
public void setInputRange(java.lang.String value)
public java.lang.String getLinkedCell(boolean isR1C1,
boolean isLocal)
Example
//You may get results like '$A$1'
String link = shape.getLinkedCell(false, false);
isR1C1 - Whether the formula needs to be formatted as R1C1.isLocal - Whether the formula needs to be formatted by locale.public void setLinkedCell(java.lang.String formula,
boolean isR1C1,
boolean isLocal)
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);
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.public java.lang.String getInputRange(boolean isR1C1,
boolean isLocal)
Example
String range = shape.getInputRange(false, true);
//If successful, a value like "$A$1:$A$3" will be returned
isR1C1 - Whether the formula needs to be formatted as R1C1.isLocal - Whether the formula needs to be formatted by locale.public void setInputRange(java.lang.String formula,
boolean isR1C1,
boolean isLocal)
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.
for (int i = 0; i ++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);
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.public void updateSelectedValue()
Example
Cell cell = null;
for (int i = 0; i ++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 int getTextShapeType()
See AutoShapeType.
Example
if (shape.getTextShapeType() == com.aspose.cells.AutoShapeType.UNKNOWN)
shape.setTextShapeType(com.aspose.cells.AutoShapeType.RECTANGLE);
public void setTextShapeType(int value)
See AutoShapeType.
public FontSettingCollection getTextBody()
Example
FontSettingCollection fontSettingCollection = shape.getTextBody();
fontSettingCollection.setText("This is a test.");
public Font getFont()
Example
Font font = shape.getFont();
font.setName("Arial");
font.setSize(12);
font.setColor(Color.getRed());
public void setFont(Font value)
public TextOptions getTextOptions()
Example
TextOptions opt = shape.getTextOptions();
opt.setColor(Color.getBlue());
opt.setSize(8);
public void setTextOptions(TextOptions value)
public int[] calculateTextSize()
Example
//The size of the text area is:w=size[0],h=size[1]
int[] size = shape.calculateTextSize();
public java.lang.String getText()
Example
if(shape.getText() == null)
shape.setText("This is a test.");
public void setText(java.lang.String value)
public boolean isRichText()
Example
if(shape.isRichText())
System.out.println("The text is rich text.");
public java.lang.String getHtmlText()
Example
String html = shape.getHtmlText();
if(html == null || "".equals(html))
{
shape.setHtmlText("<Font Style='FONT-FAMILY: Calibri;FONT-SIZE: 11pt;COLOR: #0000ff;TEXT-ALIGN: left;'>This is a <b>test</b>.</Font>");
}
public void setHtmlText(java.lang.String value)
public void formatCharacters(int startIndex,
int length,
Font font,
StyleFlag flag)
startIndex - The start index.length - The length.font - The font setting.flag - The flag of the font setting.public FontSetting characters(int startIndex, int length)
Remarks
This method only works on shape with title.Example
FontSetting fontSetting = shape.characters(0, 4);
startIndex - The index of the start of the character.length - The number of characters.public java.util.ArrayList getCharacters()
Remarks
NOTE: This method is now obsolete. Instead, please use Shape.GetRichFormattings() method. This method will be removed 12 months later since November 2023. Aspose apologizes for any inconvenience you may have experienced.Example
FontSetting fontSetting = shape.characters(0, 4);
public FontSetting[] getRichFormattings()
Example
FontSetting[] list = shape.getRichFormattings();
public int getTextVerticalOverflow()
See TextOverflowType.
Example
if (shape.getTextVerticalOverflow() == com.aspose.cells.TextOverflowType.CLIP)
shape.setTextVerticalOverflow(com.aspose.cells.TextOverflowType.OVERFLOW);
public void setTextVerticalOverflow(int value)
See TextOverflowType.
public int getTextHorizontalOverflow()
See TextOverflowType.
Example
if (shape.getTextHorizontalOverflow() == com.aspose.cells.TextOverflowType.CLIP)
shape.setTextHorizontalOverflow(com.aspose.cells.TextOverflowType.OVERFLOW);
public void setTextHorizontalOverflow(int value)
See TextOverflowType.
public boolean isTextWrapped()
Example
if (shape.isTextWrapped())
shape.setTextWrapped(!shape.isTextWrapped());
public void setTextWrapped(boolean value)
public int getTextOrientationType()
See TextOrientationType.
Example
if (shape.getTextOrientationType() == com.aspose.cells.TextOrientationType.NO_ROTATION)
shape.setTextOrientationType(com.aspose.cells.TextOrientationType.TOP_TO_BOTTOM);
public void setTextOrientationType(int value)
See TextOrientationType.
public int getTextHorizontalAlignment()
See TextAlignmentType.
Example
if (shape.getTextHorizontalAlignment() == com.aspose.cells.TextAlignmentType.BOTTOM)
shape.setTextHorizontalAlignment(com.aspose.cells.TextAlignmentType.CENTER);
public void setTextHorizontalAlignment(int value)
See TextAlignmentType.
public int getTextVerticalAlignment()
See TextAlignmentType.
Example
if (shape.getTextVerticalAlignment() == com.aspose.cells.TextAlignmentType.BOTTOM)
shape.setTextVerticalAlignment(com.aspose.cells.TextAlignmentType.CENTER);
public void setTextVerticalAlignment(int value)
See TextAlignmentType.
public int getTextDirection()
See TextDirectionType.
Example
if (shape.getTextDirection() == com.aspose.cells.TextDirectionType.CONTEXT)
shape.setTextDirection(com.aspose.cells.TextDirectionType.LEFT_TO_RIGHT);
public void setTextDirection(int value)
See TextDirectionType.
public TextBoxOptions getTextBoxOptions()
public byte[] getControlData()
Example
if(shape.getControlData() == null)
System.out.println("No data.");
public ActiveXControl getActiveXControl()
Example
if(shape.getActiveXControl() != null)
{
CheckBoxActiveXControl checkBox1 = (CheckBoxActiveXControl)shape.getActiveXControl();
//The font name of CheckBox
String fontName = checkBox1.getFont().getName();
}
public void removeActiveXControl()
Example
if(shape.getActiveXControl() != null)
{
shape.removeActiveXControl();
}
public ShapePathCollection getPaths()
Example
//Returns non-null if there is a path to the custom geometry
if(shape.getPaths() == null)
System.out.println("No custom geometry path.");
public Geometry getGeometry()
Example
if (shape.getGeometry() != null &&shape.getGeometry().getShapeAdjustValues().getCount() == 0)
System.out.println("No geometry path.");
public boolean isSameSetting(java.lang.Object obj)
Example
if (shape.isSameSetting(shape))
System.out.println("Two objects the same.");
obj - public java.util.UUID getCreateId()
public void setCreateId(java.util.UUID value)
public boolean isDecorative()
public void setDecorative(boolean value)
public float[] getActualBox()
Remarks
Note:The interface is not fully functional, especially the location information is not correct.It is recommended not to use this interface until the function is complete.public void fitToTextSize()
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.