XlsShape module
- class XlsShape.XlsShape
Bases:
XlsObject,IShape,ICloneParent,INamedObjectRepresents a shape in an Excel worksheet.
This class provides properties and methods for manipulating shapes in Excel worksheets, including positioning, sizing, appearance, and other shape-specific functionality. It serves as a base class for various shape types and implements multiple interfaces for shape manipulation.
- property AlternativeText: str
Gets or sets the alternative text for the shape.
Alternative text is used for accessibility purposes and appears when the shape cannot be displayed.
- Returns:
The alternative text for the shape.
- Return type:
str
- property AlternativeTextTitle: str
Gets or sets the descriptive (alternative) text title for the shape.
This title is used when the shape is saved to a Web page for accessibility purposes.
- Returns:
The alternative text title for the shape.
- Return type:
str
- property AutoSize: bool
Gets or sets whether the shape automatically sizes to fit its contents.
- Returns:
True if the shape automatically resizes to fit its contents; False otherwise.
- Return type:
bool
- property BottomRow: int
Gets or sets the bottom row index of the shape’s position.
This property specifies the row that contains the bottom edge of the shape.
- Returns:
The bottom row index of the shape’s position.
- Return type:
int
- property BottomRowOffset: int
Gets or sets the offset of the bottom edge of the shape from the bottom row.
This property specifies the distance in pixels from the top edge of the bottom row to the bottom edge of the shape.
- Returns:
The offset in pixels from the bottom row.
- Return type:
int
- ChangeLayer(changeType: ShapeLayerChangeType)
Changes the layer of the shape.
- Parameters:
changeType (ShapeLayerChangeType) – The type of layer change to apply.
- Clone
Creates a clone of the current shape.
- Parameters:
parent (SpireObject) – New parent for the shape object.
- Returns:
A copy of the current shape.
- Return type:
SpireObject
- property Fill: IShapeFill
Gets the fill formatting for the shape.
This property provides access to the fill formatting options such as color, gradient, texture, or pattern for the shape.
- Returns:
An object representing the fill formatting for the shape.
- Return type:
IShapeFill
- property Glow: IGlow
Gets the glow effect settings for the shape.
- Returns:
An object representing the glow effect settings of the shape.
- Return type:
IGlow
- property HasFill: bool
Gets or sets whether the shape has fill formatting.
- Returns:
True if the shape has fill formatting; otherwise, False.
- Return type:
bool
- property HasLineFormat: bool
Gets or sets whether the shape has line formatting.
- Returns:
True if the shape has line formatting; otherwise, False.
- Return type:
bool
- property Height: int
Gets or sets the height of the shape in pixels.
- Returns:
The height of the shape.
- Return type:
int
- property HtmlString: str
Gets or sets the HTML string representation of the shape.
This property allows accessing or modifying the shape’s content as HTML.
- Returns:
The HTML string representation of the shape.
- Return type:
str
- property ID: int
Gets the unique identifier of the shape.
- Returns:
The unique identifier of the shape.
- Return type:
int
- property Instance: int
Gets the instance number of the shape.
This is a unique identifier for the shape instance.
- Returns:
The instance number of the shape.
- Return type:
int
- property IsFlipH: bool
Gets or sets whether the shape is flipped horizontally.
- Returns:
True if the shape is flipped horizontally; otherwise, False.
- Return type:
bool
- property IsFlipV: bool
Gets or sets whether the shape is flipped vertically.
- Returns:
True if the shape is flipped vertically; otherwise, False.
- Return type:
bool
- property IsGroup: bool
Gets whether the shape is a group shape.
A group shape contains multiple individual shapes grouped together.
- Returns:
True if the shape is a group shape; otherwise, False.
- Return type:
bool
- property IsInGroup: bool
Gets whether the shape is a child shape within a group shape.
- Returns:
True if the shape is a child shape within a group shape; otherwise, False.
- Return type:
bool
- property IsLockAspectRatio: bool
- property IsLocked: bool
Gets or sets whether the shape is locked.
When a shape is locked, it cannot be selected or modified when the worksheet is protected.
- Returns:
True if the shape is locked; otherwise, False.
- Return type:
bool
- property IsPrintable: bool
Gets or sets whether the shape is printed when the worksheet is printed.
- Returns:
True if the shape is printed with the worksheet; otherwise, False.
- Return type:
bool
- property IsRelative: bool
Gets or sets whether the shape has relative positioning.
When True, the shape position is calculated relative to the worksheet cells.
- Returns:
True if the shape has relative positioning; otherwise, False.
- Return type:
bool
- property IsRelativeResize: bool
Gets or sets whether the shape is resized relative to the original size.
When True, the shape will maintain its proportions when resized.
- Returns:
True if the shape is resized relative to the original size; otherwise, False.
- Return type:
bool
- property IsShortVersion: bool
Gets or sets whether the shape is using the short version format.
- Returns:
True if the shape is using the short version format; otherwise, False.
- Return type:
bool
- property IsSmartArt: bool
Gets whether the shape is a SmartArt object.
- Returns:
True if the shape is a SmartArt object; False otherwise.
- Return type:
bool
- property Left: int
Gets or sets the position of the left edge of the shape in pixels.
- Returns:
The position of the left edge of the shape.
- Return type:
int
- property LeftColumn: int
Gets or sets the left column index of the shape’s position.
This property specifies the column that contains the left edge of the shape.
- Returns:
The left column index of the shape’s position.
- Return type:
int
- property LeftColumnOffset: int
Gets or sets the offset of the left edge of the shape from the left column.
This property specifies the distance in pixels from the left edge of the left column to the left edge of the shape. A value of 1024 represents a whole column offset.
- Returns:
The offset in pixels from the left column.
- Return type:
int
- property Line: IShapeLineFormat
Gets the line format of the shape.
- Returns:
An object representing the line format settings of the shape.
- Return type:
IShapeLineFormat
- property LinkedCell: IXLSRange
Gets or sets the cell linked to the shape.
- Returns:
A range object representing the cell linked to the shape.
- Return type:
IXLSRange
- property Name: str
Gets or sets the name of the shape.
- Returns:
The name of the shape.
- Return type:
str
- property OnAction: str
Gets or sets the name of the macro or action associated with the shape.
This macro or action is executed when the shape is clicked.
- Returns:
The name of the macro or action associated with the shape.
- Return type:
str
- property Reflection: IReflectionEffect
Gets the reflection effect settings for the shape.
- Returns:
An object representing the reflection effect settings of the shape.
- Return type:
IReflectionEffect
- Remove
Removes the shape from the worksheet.
This method deletes the shape from the worksheet and releases any resources associated with it.
- property ResizeBehave: ResizeBehaveType
Gets or sets how the shape behaves when rows and columns are resized or inserted.
Specifies all possible settings for how the drawing object will be resized when the rows and columns between its start and ending anchor are resized or inserted. Note: For ComboBoxShape, CheckBoxShape, and RadioButtonShape, the MoveAndResize type value is invalid.
- Returns:
An enumeration value representing the resize behavior.
- Return type:
ResizeBehaveType
- property RichText: IRichTextString
Gets the rich text formatting for the text in the shape.
- Returns:
An object representing the rich text formatting of the shape’s text.
- Return type:
IRichTextString
- property RightColumn: int
Gets or sets the right column index of the shape’s position.
This property specifies the column that contains the right edge of the shape.
- Returns:
The right column index of the shape’s position.
- Return type:
int
- property RightColumnOffset: int
Gets or sets the offset of the right edge of the shape from the right column.
This property specifies the distance in pixels from the left edge of the right column to the right edge of the shape.
- Returns:
The offset in pixels from the right column.
- Return type:
int
- property Rotation: int
Returns or sets the rotation of the shape, in degrees.
- SaveToImage
Save shape to image.
- Parameters:
fileStream – Output stream. It is ignored if null.
- Scale(scaleWidth: int, scaleHeight: int)
Scales the shape by the specified percentages.
This method resizes the shape according to the specified width and height scaling factors.
- Parameters:
scaleWidth (int) – Width scaling factor as a percentage of the original width.
scaleHeight (int) – Height scaling factor as a percentage of the original height.
- SetName(name: str)
Sets the name of the shape.
- Parameters:
name (str) – The name to set for the shape.
- SetTextEffect(effect: PresetTextEffect, text: str)
Apply a text effect to the shape.
- Parameters:
effect (PresetTextEffect) – The preset text effect to apply.
text (str) – The text to which the effect will be applied.
- property Shadow: IShadow
Gets the shadow effect settings for the shape.
- Returns:
An object representing the shadow effect settings of the shape.
- Return type:
IShadow
- property ShapeCount: int
Gets the number of shapes in a group shape.
If this shape is a group shape, this property returns the number of shapes it contains.
- Returns:
The number of shapes in a group shape.
- Return type:
int
- property ShapeId: int
Gets or sets the shape identifier.
- Returns:
The shape identifier.
- Return type:
int
- property ShapeType: ExcelShapeType
Gets or sets the type of the shape.
- Returns:
An enumeration value representing the shape type.
- Return type:
ExcelShapeType
- property TextFrame: ITextFrame
Gets the text frame of the shape.
- Returns:
An object representing the text frame settings of the shape.
- Return type:
ITextFrame
- property TextVerticalAlignment: ExcelVerticalAlignment
Gets or sets the vertical alignment of text in the shape.
- Returns:
An enumeration value representing the vertical alignment of text.
- Return type:
ExcelVerticalAlignment
- property ThreeD: IFormat3D
Gets the 3D format settings for the shape.
- Returns:
An object representing the 3D format settings of the shape.
- Return type:
IFormat3D
- property Top: int
Gets or sets the position of the top edge of the shape in pixels.
- Returns:
The position of the top edge of the shape.
- Return type:
int
- property TopRow: int
Gets or sets the top row index of the shape’s position.
This property specifies the row that contains the top edge of the shape.
- Returns:
The top row index of the shape’s position.
- Return type:
int
- property TopRowOffset: int
Gets or sets the offset of the top edge of the shape from the top row.
This property specifies the distance in pixels from the top edge of the top row to the top edge of the shape. A value of 256 represents a whole row offset.
- Returns:
The offset in pixels from the top row.
- Return type:
int
- property UpdatePositions: bool
Gets or sets whether the shape positions should be updated.
When True, the shape’s position will be updated when changes occur in the worksheet.
- Returns:
True if shape positions should be updated; otherwise, False.
- Return type:
bool
- property Visible: bool
Gets or sets whether the shape is visible.
- Returns:
True if the shape is visible; otherwise, False.
- Return type:
bool
- property VmlShape: bool
Gets or sets whether the shape is a VML shape.
VML (Vector Markup Language) shapes are an older format used in Excel.
- Returns:
True if the shape is a VML shape; otherwise, False.
- Return type:
bool
- property Width: int
Gets or sets the width of the shape in pixels.
- Returns:
The width of the shape.
- Return type:
int
