Class Shape
Namespace: Aspose.Cells.Drawing
Assembly: Aspose.Cells.dll (25.2.0)
Represents the msodrawing object.
public class Shape
Inheritance
Derived
ArcShape, Button, CellsDrawing, ChartShape, CheckBox, ComboBox, CommentShape, CustomXmlShape, DialogBox, GroupBox, GroupShape, Label, LineShape, ListBox, OleObject, Oval, Picture, RadioButton, RectangleShape, ScrollBar, SmartArtShape, Spinner, TextBox, WebExtensionShape
Inherited Members
object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Examples
csharp
[C#]
//Initialize a new workbook.
Workbook book = new Workbook();
//Add a shape.(e.g rectangle)
Aspose.Cells.Drawing.Shape shape = book.Worksheets[0].Shapes.AddRectangle(2, 0, 2, 0, 130, 130);
//do your business
//Save the excel file.
book.Save("exmaple.xlsx");
Properties
ActiveXControl
Gets the ActiveX control.
public ActiveXControl ActiveXControl { get; }
Property Value
Examples
csharp
[C#]
if(shape.ActiveXControl != null)
{
CheckBoxActiveXControl checkBox1 = (CheckBoxActiveXControl)shape.ActiveXControl;
//The font name of CheckBox
string fontName = checkBox1.Font.Name;
}
ActualLowerRightRow
Get the actual bottom row.
public int ActualLowerRightRow { get; }
Property Value
Examples
csharp
[C#]
int rRow = shape.ActualLowerRightRow;
AlternativeText
Returns or sets the descriptive (alternative) text string of the Aspose.Cells.Drawing.Shape object.
public string AlternativeText { get; set; }
Property Value
Examples
csharp
[C#]
shape.AlternativeText = "a rectangle";
AnchorType
Gets and set the type of the shape anchor placeholder.
public ShapeAnchorType AnchorType { get; set; }
Property Value
Examples
csharp
[C#]
if (shape.AnchorType == ShapeAnchorType.OneCellAnchor)
shape.AnchorType = ShapeAnchorType.TwoCellAnchor;
AutoShapeType
Gets and sets the auto shape type.
public AutoShapeType AutoShapeType { get; set; }
Property Value
Examples
csharp
[C#]
if (shape.AutoShapeType == Aspose.Cells.Drawing.AutoShapeType.Unknown)
shape.AutoShapeType = Aspose.Cells.Drawing.AutoShapeType.Rectangle;
Bottom
Represents the width of the shape’s vertical offset from its lower bottom corner row, in unit of pixels.
public int Bottom { get; set; }
Property Value
Examples
csharp
[C#]
if (shape.Bottom == 3)
shape.Bottom = 1;
ControlData
Gets the data of control.
public byte[] ControlData { get; }
Property Value
byte[]
Examples
csharp
[C#]
if(shape.ControlData == null)
Console.WriteLine("No data.");
CreateId
Gets and sets create id for this shape.
public Guid CreateId { get; set; }
Property Value
Fill
Returns a Aspose.Cells.Drawing.Shape.FillFormat object that contains fill formatting properties for the specified shape.
public FillFormat Fill { get; }
Property Value
Examples
csharp
[C#]
Aspose.Cells.Drawing.FillFormat fillFmt = shape.Fill;
Font
Represents the font of shape.
public Font Font { get; set; }
Property Value
Examples
csharp
[C#]
Aspose.Cells.Font font = shape.Font;
font.Name = "Arial";
font.Size = 12;
font.Color = Color.Red;
FormatPicture
Gets and sets the options of the picture format.
public MsoFormatPicture FormatPicture { get; }
Property Value
Examples
csharp
[C#]
Aspose.Cells.Drawing.MsoFormatPicture msoFormatPicture = shape.FormatPicture;
Geometry
Gets the geometry
public Geometry Geometry { get; }
Property Value
Examples
csharp
[C#]
if (shape.Geometry != null && shape.Geometry.ShapeAdjustValues.Count == 0)
Console.WriteLine("No geometry path.");
Glow
Represents a Aspose.Cells.Drawing.GlowEffect object that specifies glow effect for the chart element or shape.
public GlowEffect Glow { get; }
Property Value
Examples
csharp
[C#]
Aspose.Cells.Drawing.GlowEffect glowEffect = shape.Glow;
Group
Gets the group shape which contains this shape.
public GroupShape Group { get; }
Property Value
Examples
csharp
[C#]
Aspose.Cells.Drawing.GroupShape groupShape = shape.Group;
HasLine
Gets and sets the line border of the shape is visible.
public bool HasLine { get; set; }
Property Value
Examples
csharp
[C#]
if(shape.HasLine == false)
shape.HasLine = true;
Height
Represents the height of shape, in unit of pixel.
public int Height { get; set; }
Property Value
Examples
csharp
[C#]
if (shape.Height == 3)
shape.Height = 1;
HeightCM
Represents the height of the shape, in unit of centimeters.
public double HeightCM { get; set; }
Property Value
Examples
csharp
[C#]
if (shape.HeightCM == 3)
shape.HeightCM = 1;
HeightInShape
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..
public int HeightInShape { get; set; }
Property Value
Examples
csharp
[C#]
if (shape.IsInGroup && shape.HeightInShape == 4000)
shape.HeightInShape = 2000;
Remarks
Only Applies when this shape in the group or chart.
HeightInch
Represents the height of the shape, in unit of inches.
public double HeightInch { get; set; }
Property Value
Examples
csharp
[C#]
if (shape.HeightInch == 3)
shape.HeightInch = 1;
HeightPt
Represents the height of the shape, in unit of points.
public double HeightPt { get; set; }
Property Value
Examples
csharp
[C#]
if (shape.HeightPt == 3)
shape.HeightPt = 1;
HeightScale
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;
public int HeightScale { get; set; }
Property Value
Examples
csharp
[C#]
if (shape.HeightScale == 3)
shape.HeightScale = 1;
HtmlText
Gets and sets the html string which contains data and some formats in this textbox.
public string HtmlText { get; set; }
Property Value
Examples
csharp
[C#]
string html = shape.HtmlText;
if(html == null || html == "")
{
shape.HtmlText = "<Font Style='FONT-FAMILY: Calibri;FONT-SIZE: 11pt;COLOR: #0000ff;TEXT-ALIGN: left;'>This is a <b>test</b>.</Font>";
}
Hyperlink
Gets the hyperlink of the shape.
public Hyperlink Hyperlink { get; }
Property Value
Examples
csharp
[C#]
Aspose.Cells.Hyperlink hyperlink = shape.Hyperlink;
Id
Gets the identifier of this shape.
public int Id { get; }
Property Value
Examples
csharp
[C#]
int id = shape.Id;
InputRange
Gets or sets the worksheet range used to fill the specified combo box.
public string InputRange { get; set; }
Property Value
Examples
csharp
[C#]
if (shape.InputRange.Equals("$B$6:$B10"))
shape.InputRange = "$A$1:$A$5";
IsAspectRatioLocked
True means that aspect ratio of the shape is locked.
public bool IsAspectRatioLocked { get; set; }
Property Value
Examples
csharp
[C#]
shape.IsAspectRatioLocked = false;
Remarks
Only for pictures and Ole Objects.
IsDecorative
Indicates whether the object is decorative.
public bool IsDecorative { get; set; }
Property Value
IsEquation
Indicates whether the shape only contains an equation.
public bool IsEquation { get; }
Property Value
Examples
csharp
[C#]
//If true,the shape only contains an equation.
if(shape.IsEquation)
{
//The shape contains only an equation
}
IsFilled
Indicates whether the fill format is visible.
public bool IsFilled { get; set; }
Property Value
Examples
csharp
[C#]
if(shape.IsFilled == false)
shape.IsFilled = true;
IsFlippedHorizontally
Gets and sets whether shape is horizontally flipped .
public bool IsFlippedHorizontally { get; set; }
Property Value
Examples
csharp
[C#]
if(shape.IsFlippedHorizontally == false)
shape.IsFlippedHorizontally = true;
IsFlippedVertically
Gets and sets whether shape is vertically flipped .
public bool IsFlippedVertically { get; set; }
Property Value
Examples
csharp
[C#]
if(shape.IsFlippedVertically == false)
shape.IsFlippedVertically = true;
IsGroup
Indicates whether this shape is a group shape.
public bool IsGroup { get; }
Property Value
Examples
csharp
[C#]
if(shape.IsGroup)
{
//This shape is a group.
}
IsHidden
Indicates whether the object is visible.
public bool IsHidden { get; set; }
Property Value
Examples
csharp
[C#]
shape.IsHidden = false;
IsInGroup
Indicates whether the shape is grouped.
public bool IsInGroup { get; }
Property Value
IsLocked
True means the object can not be modified when the sheet is protected. Note that this value is meaningful only if the worksheet or objects in the worksheet are protected.
public bool IsLocked { get; set; }
Property Value
Examples
csharp
[C#]
//Sets the specified shape to unlocked state
if (shape.Worksheet.IsProtected && shape.IsLocked)
{
shape.IsLocked = false;
}
//Sets the specified shape to a locked state
if (shape.Worksheet.IsProtected && !shape.IsLocked)
{
shape.IsLocked = true;
}
IsPrintable
Indicates whether the object is printable. If False, this shape will not be printed when printing.
public bool IsPrintable { get; set; }
Property Value
Examples
csharp
[C#]
if(shape.IsPrintable)
shape.IsPrintable = false;
IsRichText
Whether or not the text is rich text.
public bool IsRichText { get; }
Property Value
Examples
csharp
[C#]
if(shape.IsRichText)
Console.WriteLine("The text is rich text.");
IsSmartArt
Indicates whether the shape is a smart art.
public bool IsSmartArt { get; }
Property Value
Examples
csharp
[C#]
//if true,the shape is a smart art.
if(shape.IsSmartArt)
{
//The shape is SmartArt object.
}
Remarks
Only for ooxml file.
IsTextWrapped
Gets and sets the text wrapped type of the shape which contains text.
public bool IsTextWrapped { get; set; }
Property Value
Examples
csharp
[C#]
if (shape.IsTextWrapped)
shape.IsTextWrapped = !shape.IsTextWrapped;
IsWordArt
Indicates whether this shape is a word art.
public bool IsWordArt { get; }
Property Value
Examples
csharp
[C#]
if(shape.IsWordArt)
{
//This shape is a WordArt object.
}
Remarks
Only for the Legacy Shape of xls file.
Left
Represents the horizontal offset of shape from its left column, in unit of pixels.
public int Left { get; set; }
Property Value
Examples
csharp
[C#]
if (shape.Left == 3)
shape.Left = 1;
LeftCM
Represents the horizontal offset of shape from its left column, in unit of centimeters.
public double LeftCM { get; set; }
Property Value
Examples
csharp
[C#]
if (shape.LeftCM == 3)
shape.LeftCM = 1;
LeftInShape
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.
public int LeftInShape { get; set; }
Property Value
Examples
csharp
[C#]
if (shape.IsInGroup && shape.LeftInShape == 2000)
shape.LeftInShape = 4000;
Remarks
Only Applies when this shape in the group or chart.
LeftInch
Represents the horizontal offset of shape from its left column, in unit of inches.
public double LeftInch { get; set; }
Property Value
Examples
csharp
[C#]
if (shape.LeftInch == 3)
shape.LeftInch = 1;
LeftToCorner
Gets and sets the horizonal offset of shape from worksheet left border.
public int LeftToCorner { get; set; }
Property Value
Examples
csharp
[C#]
if (shape.LeftToCorner == 3)
shape.LeftToCorner = 1;
Line
Gets line style
public LineFormat Line { get; }
Property Value
Examples
csharp
[C#]
Aspose.Cells.Drawing.LineFormat lineFmt = shape.Line;
LinkedCell
Gets or sets the worksheet range linked to the control’s value.
public string LinkedCell { get; set; }
Property Value
Examples
csharp
[C#]
if (shape.LinkedCell.Equals("$B$6"))
shape.LinkedCell = "A1";
LowerDeltaX
Gets or sets the shape’s horizontal offset from its lower right corner column.
public int LowerDeltaX { get; set; }
Property Value
Examples
csharp
[C#]
if (shape.LowerDeltaX == 3)
shape.LowerDeltaX = 1;
Remarks
The range of value is 0 to 1024.
LowerDeltaY
Gets or sets the shape’s vertical offset from its lower right corner row.
public int LowerDeltaY { get; set; }
Property Value
Examples
csharp
[C#]
if (shape.LowerDeltaY == 3)
shape.LowerDeltaY = 1;
Remarks
The range of value is 0 to 256.
LowerRightColumn
Represents lower right corner column index.
public int LowerRightColumn { get; set; }
Property Value
Examples
csharp
[C#]
if (shape.LowerRightColumn == 3)
shape.LowerRightColumn = 1;
LowerRightRow
Represents lower right corner row index.
public int LowerRightRow { get; set; }
Property Value
Examples
csharp
[C#]
if (shape.LowerRightRow == 3)
shape.LowerRightRow = 1;
MacroName
Gets and sets the name of macro.
public string MacroName { get; set; }
Property Value
Examples
csharp
[C#]
//Sets the name of macro.
shape.MacroName = "DoWork()";
MsoDrawingType
Gets drawing type.
public MsoDrawingType MsoDrawingType { get; }
Property Value
Examples
csharp
[C#]
Aspose.Cells.Drawing.MsoDrawingType msoDrawingType = shape.MsoDrawingType;
Name
Gets and sets the name of the shape.
public string Name { get; set; }
Property Value
Examples
csharp
[C#]
shape.Name = "shape1";
Paths
Gets the paths of a custom geometric shape.
public ShapePathCollection Paths { get; }
Property Value
Examples
csharp
[C#]
//Returns non-null if there is a path to the custom geometry
if(shape.Paths == null)
Console.WriteLine("No custom geometry path.");
Placement
Represents the way the drawing object is attached to the cells below it. The property controls the placement of an object on a worksheet.
public PlacementType Placement { get; set; }
Property Value
Examples
csharp
[C#]
if (shape.Placement == PlacementType.Move)
shape.Placement = PlacementType.MoveAndSize;
Reflection
Represents a Aspose.Cells.Drawing.ReflectionEffect object that specifies reflection effect for the chart element or shape.
public ReflectionEffect Reflection { get; }
Property Value
Examples
csharp
[C#]
Aspose.Cells.Drawing.ReflectionEffect reflectionEffect = shape.Reflection;
RelativeToOriginalPictureSize
Indicates whether shape is relative to original picture size.
public bool RelativeToOriginalPictureSize { get; set; }
Property Value
Examples
csharp
[C#]
if(shape.RelativeToOriginalPictureSize)
shape.RelativeToOriginalPictureSize = false;
Right
Represents the width of the shape’s horizontal offset from its lower right corner column, in unit of pixels.
public int Right { get; set; }
Property Value
Examples
csharp
[C#]
if (shape.Right == 3)
shape.Right = 1;
RotationAngle
Gets and sets the rotation of the shape.
public double RotationAngle { get; set; }
Property Value
Examples
csharp
[C#]
//Gets rotation angle of the shape.
double angle = shape.RotationAngle ;
//Gets rotation angle of the shape.
shape.RotationAngle = 60;
ShadowEffect
Represents a Aspose.Cells.Drawing.ShadowEffect object that specifies shadow effect for the chart element or shape.
public ShadowEffect ShadowEffect { get; }
Property Value
Examples
csharp
[C#]
Aspose.Cells.Drawing.ShadowEffect shadowEffect = shape.ShadowEffect;
SoftEdges
Gets and sets the radius of blur to apply to the edges, in unit of points.
public double SoftEdges { get; set; }
Property Value
Examples
csharp
[C#]
shape.SoftEdges = 0.5d;
Spid
Specifies an optional string identifier that an application can use to identify the particular shape.
public string Spid { get; }
Property Value
Examples
csharp
[C#]
string spid = shape.Spid;
Spt
Specifies an optional number that an application can use to associate the particular shape with a defined shape type.
public int Spt { get; }
Property Value
Examples
csharp
[C#]
int spt = shape.Spt;
Text
Gets and sets the text of this shape.
public string Text { get; set; }
Property Value
Examples
csharp
[C#]
if(shape.Text == null)
shape.Text = "This is a test.";
TextBody
Gets and sets the setting of the shape’s text.
public FontSettingCollection TextBody { get; }
Property Value
Examples
csharp
[C#]
Aspose.Cells.Drawing.Texts.FontSettingCollection fontSettingCollection = shape.TextBody;
fontSettingCollection.Text = "This is a test.";
TextBoxOptions
Gets the text information in the shape
public TextBoxOptions TextBoxOptions { get; }
Property Value
TextDirection
Gets/Sets the direction of the text flow for this object.
public TextDirectionType TextDirection { get; set; }
Property Value
Examples
csharp
[C#]
if (shape.TextDirection == Aspose.Cells.TextDirectionType.Context)
shape.TextDirection = Aspose.Cells.TextDirectionType.LeftToRight;
TextEffect
Returns a TextEffectFormat object that contains text-effect formatting properties for the specified shape. Applies to Shape objects that represent WordArt.
public TextEffectFormat TextEffect { get; }
Property Value
Examples
csharp
[C#]
if(shape.IsWordArt)
{
Aspose.Cells.Drawing.TextEffectFormat textEffectFormat = shape.TextEffect;
}
TextHorizontalAlignment
Gets and sets the text horizontal alignment type of the shape.
public TextAlignmentType TextHorizontalAlignment { get; set; }
Property Value
Examples
csharp
[C#]
if (shape.TextHorizontalAlignment == Aspose.Cells.TextAlignmentType.Bottom)
shape.TextHorizontalAlignment = Aspose.Cells.TextAlignmentType.Center;
TextHorizontalOverflow
Gets and sets the text horizontal overflow type of the shape which contains text.
public TextOverflowType TextHorizontalOverflow { get; set; }
Property Value
Examples
csharp
[C#]
if (shape.TextHorizontalOverflow == Aspose.Cells.Drawing.TextOverflowType.Clip)
shape.TextHorizontalOverflow = Aspose.Cells.Drawing.TextOverflowType.Overflow;
TextOptions
Represents the text options of the shape.
public TextOptions TextOptions { get; set; }
Property Value
Examples
csharp
[C#]
Aspose.Cells.Drawing.Texts.TextOptions opt = shape.TextOptions;
opt.Color = Color.Blue;
opt.Size = 8;
TextOrientationType
Gets and sets the text orientation type of the shape.
public TextOrientationType TextOrientationType { get; set; }
Property Value
Examples
csharp
[C#]
if (shape.TextOrientationType == Aspose.Cells.TextOrientationType.NoRotation)
shape.TextOrientationType = Aspose.Cells.TextOrientationType.TopToBottom;
TextShapeType
Gets and sets the preset text shape type.
public AutoShapeType TextShapeType { get; set; }
Property Value
Examples
csharp
[C#]
if (shape.TextShapeType == Aspose.Cells.Drawing.AutoShapeType.Unknown)
shape.TextShapeType = Aspose.Cells.Drawing.AutoShapeType.Rectangle;
TextVerticalAlignment
Gets and sets the text vertical alignment type of the shape.
public TextAlignmentType TextVerticalAlignment { get; set; }
Property Value
Examples
csharp
[C#]
if (shape.TextVerticalAlignment == Aspose.Cells.TextAlignmentType.Bottom)
shape.TextVerticalAlignment = Aspose.Cells.TextAlignmentType.Center;
TextVerticalOverflow
Gets and sets the text vertical overflow type of the shape which contains text.
public TextOverflowType TextVerticalOverflow { get; set; }
Property Value
Examples
csharp
[C#]
if (shape.TextVerticalOverflow == Aspose.Cells.Drawing.TextOverflowType.Clip)
shape.TextVerticalOverflow = Aspose.Cells.Drawing.TextOverflowType.Overflow;
ThreeDFormat
Gets and sets 3d format of the shape.
public ThreeDFormat ThreeDFormat { get; }
Property Value
Examples
csharp
[C#]
Aspose.Cells.Drawing.ThreeDFormat threeDFormat = shape.ThreeDFormat;
Title
Specifies the title (caption) of the current shape object.
public string Title { get; set; }
Property Value
Examples
csharp
[C#]
shape.Title = "title1";
Top
Represents the vertical offset of shape from its top row, in unit of pixels.
public int Top { get; set; }
Property Value
Examples
csharp
[C#]
if (shape.Top == 3)
shape.Top = 1;
Remarks
If the shape is in the chart, represents the vertical offset of shape from its top border.
TopCM
Represents the vertical offset of shape from its top row, in unit of centimeters.
public double TopCM { get; set; }
Property Value
Examples
csharp
[C#]
if (shape.TopCM == 3)
shape.TopCM = 1;
TopInShape
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.
public int TopInShape { get; set; }
Property Value
Examples
csharp
[C#]
if (shape.IsInGroup && shape.TopInShape == 8000)
shape.TopInShape = 4000;
Remarks
Only Applies when this shape in the group or chart.
TopInch
Represents the vertical offset of shape from its top row, in unit of inches.
public double TopInch { get; set; }
Property Value
Examples
csharp
[C#]
if (shape.TopInch == 3)
shape.TopInch = 1;
TopToCorner
Gets and sets the vertical offset of shape from worksheet top border, in unit of pixels.
public int TopToCorner { get; set; }
Property Value
Examples
csharp
[C#]
if (shape.TopToCorner == 3)
shape.TopToCorner = 1;
Type
Gets the auto shape type.
public AutoShapeType Type { get; }
Property Value
Examples
csharp
[C#]
Aspose.Cells.Drawing.AutoShapeType autoShapeType = shape.Type;
UpperDeltaX
Gets or sets the shape’s horizontal offset from its upper left corner column.
public int UpperDeltaX { get; set; }
Property Value
Examples
csharp
[C#]
if (shape.UpperDeltaX == 3)
shape.UpperDeltaX = 1;
Remarks
The range of value is 0 to 1024.
UpperDeltaY
Gets or sets the shape’s vertical offset from its upper left corner row.
public int UpperDeltaY { get; set; }
Property Value
Examples
csharp
[C#]
if (shape.UpperDeltaY == 3)
shape.UpperDeltaY = 1;
Remarks
The range of value is 0 to 256.
UpperLeftColumn
Represents upper left corner column index.
public int UpperLeftColumn { get; set; }
Property Value
Examples
csharp
[C#]
if (shape.UpperLeftColumn == 3)
shape.UpperLeftColumn = 1;
UpperLeftRow
Represents the top row index.
public int UpperLeftRow { get; set; }
Property Value
Examples
csharp
[C#]
if (shape.UpperLeftRow == 3)
shape.UpperLeftRow = 1;
Remarks
If the shape is in the shape or in the group , UpperLeftRow will be ignored.
Width
Represents the width of shape, in unit of pixels.
public int Width { get; set; }
Property Value
Examples
csharp
[C#]
if (shape.Width == 3)
shape.Width = 1;
WidthCM
Represents the width of the shape, in unit of centimeters.
public double WidthCM { get; set; }
Property Value
Examples
csharp
[C#]
if (shape.WidthCM == 3)
shape.WidthCM = 1;
WidthInShape
Represents the width of the shape, in unit of 1/4000 of the parent shape.
public int WidthInShape { get; set; }
Property Value
Examples
csharp
[C#]
if (shape.IsInGroup && shape.WidthInShape == 2000)
shape.WidthInShape = 4000;
Remarks
Only Applies when this shape in the group or chart.
WidthInch
Represents the width of the shape, in unit of inch.
public double WidthInch { get; set; }
Property Value
Examples
csharp
[C#]
if (shape.WidthInch == 3)
shape.WidthInch = 1;
WidthPt
Represents the width of the shape, in unit of point.
public double WidthPt { get; set; }
Property Value
Examples
csharp
[C#]
if (shape.WidthPt == 3)
shape.WidthPt = 1;
WidthScale
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;
public int WidthScale { get; set; }
Property Value
Examples
csharp
[C#]
if (shape.WidthScale == 3)
shape.WidthScale = 1;
Worksheet
Gets the Aspose.Cells.Drawing.Shape.Worksheet object which contains this shape.
public Worksheet Worksheet { get; }
Property Value
Examples
csharp
[C#]
Aspose.Cells.Worksheet worksheet = shape.Worksheet;
X
Gets and sets the horizontal offset of shape from worksheet left border,in unit of pixels.
public int X { get; set; }
Property Value
Examples
csharp
[C#]
if (shape.X == 3)
shape.X = 1;
Y
Gets and sets the vertical offset of shape from worksheet top border,in unit of pixels.
public int Y { get; set; }
Property Value
Examples
csharp
[C#]
if (shape.Y == 3)
shape.Y = 1;
ZOrderPosition
Returns the position of a shape in the z-order.
public int ZOrderPosition { get; set; }
Property Value
Examples
csharp
[C#]
shape.ZOrderPosition = 3;
Methods
AddHyperlink(string)
Adds a hyperlink to the shape.
public Hyperlink AddHyperlink(string address)
Parameters
address
string
Address of the hyperlink.
Returns
Return the new hyperlink object.
Examples
csharp
[C#]
Aspose.Cells.Hyperlink hyperlink = shape.AddHyperlink("https://www.aspose.com/");
AlignTopRightCorner(int, int)
Moves the picture to the top-right corner.
public void AlignTopRightCorner(int topRow, int rightColumn)
Parameters
topRow
int
the row index.
rightColumn
int
the column index.
Examples
csharp
[C#]
shape.AlignTopRightCorner(2, 5);
CalculateTextSize()
Recalculate the text area
public int[] CalculateTextSize()
Returns
int[]
Text’s Size in an array(width and height).
Examples
csharp
[C#]
//The size of the text area is:w=size[0],h=size[1]
int[] size = shape.CalculateTextSize();
Characters(int, int)
Returns a Characters object that represents a range of characters within the text.
public FontSetting Characters(int startIndex, int length)
Parameters
startIndex
int
The index of the start of the character.
length
int
The number of characters.
Returns
Characters object.
Examples
csharp
[C#]
Aspose.Cells.FontSetting fontSetting = shape.Characters(0, 4);
Remarks
This method only works on shape with title.
FormatCharacters(int, int, Font, StyleFlag)
Formats some characters with the font setting.
public void FormatCharacters(int startIndex, int length, Font font, StyleFlag flag)
Parameters
startIndex
int
The start index.
length
int
The length.
font
Font
The font setting.
flag
StyleFlag
The flag of the font setting.
GetActualBox()
Get the actual position and size of the shape (after applying rotation, flip, etc.)
public float[] GetActualBox()
Returns
float[]
Return the position and size in the order of x, y, w, h
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.
GetConnectionPoints()
Get the connection points
public float[][] GetConnectionPoints()
Returns
float[][]
[X,Y] pairs of the connection point. Every item is a float[2] array, [0] represents x and [1] represents y.
Examples
csharp
[C#]
float[][] points = shape.GetConnectionPoints();
GetInputRange(bool, bool)
Gets the range used to fill the control.
public string GetInputRange(bool isR1C1, bool isLocal)
Parameters
isR1C1
bool
Whether the formula needs to be formatted as R1C1.
isLocal
bool
Whether the formula needs to be formatted by locale.
Returns
The range used to fill the control.
Examples
csharp
[C#]
string range = shape.GetInputRange(false, true);
//If successful, a value like "$A$1:$A$3" will be returned
GetLinkedCell(bool, bool)
Gets the range linked to the control’s value.
public string GetLinkedCell(bool isR1C1, bool isLocal)
Parameters
isR1C1
bool
Whether the formula needs to be formatted as R1C1.
isLocal
bool
Whether the formula needs to be formatted by locale.
Returns
The range linked to the control’s value.
Examples
csharp
[C#]
//You may get results like '$A$1'
string link = shape.GetLinkedCell(false, false);
GetLockedProperty(ShapeLockType)
Gets the value of locked property.
public bool GetLockedProperty(ShapeLockType type)
Parameters
type
ShapeLockType
The type of the shape locked property.
Returns
Returns the value of locked property.
Examples
csharp
[C#]
int noAdjustHandles = 0;
if (shape.GetLockedProperty(ShapeLockType.AdjustHandles))
noAdjustHandles = 1;
GetResultOfSmartArt()
Converting smart art to grouped shapes.
public virtual GroupShape GetResultOfSmartArt()
Returns
Examples
csharp
[C#]
if(shape.IsSmartArt)
{
Aspose.Cells.Drawing.GroupShape groupShape = shape.GetResultOfSmartArt();
}
GetRichFormattings()
Returns all Characters objects that represents a range of characters within the text .
public FontSetting[] GetRichFormattings()
Returns
All Characters objects
Examples
csharp
[C#]
FontSetting[] list = shape.GetRichFormattings();
IsSameSetting(object)
Returns whether the shape is same.
public virtual bool IsSameSetting(object obj)
Parameters
obj
object
Returns
Examples
csharp
[C#]
if (shape.IsSameSetting(shape))
Console.WriteLine("Two objects the same.");
MoveToRange(int, int, int, int)
Moves the shape to a specified range.
public void MoveToRange(int upperLeftRow, int upperLeftColumn, int lowerRightRow, int lowerRightColumn)
Parameters
upperLeftRow
int
Upper left row index.
upperLeftColumn
int
Upper left column index.
lowerRightRow
int
Lower right row index
lowerRightColumn
int
Lower right column index
Examples
csharp
[C#]
shape.MoveToRange(12, 3, 13, 5);
RemoveActiveXControl()
Remove activeX control.
public void RemoveActiveXControl()
Examples
csharp
[C#]
if(shape.ActiveXControl != null)
{
shape.RemoveActiveXControl();
}
RemoveHyperlink()
Removes the hyperlink of the shape.
public void RemoveHyperlink()
Examples
csharp
[C#]
shape.RemoveHyperlink();
SetInputRange(string, bool, bool)
Sets the range used to fill the control.
public void SetInputRange(string formula, bool isR1C1, bool isLocal)
Parameters
formula
string
The range used to fill the control.
isR1C1
bool
Whether the formula needs to be formatted as R1C1.
isLocal
bool
Whether the formula needs to be formatted by locale.
Examples
csharp
[C#]
//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< 10; ++i)
{
Cell cell = book.Worksheets[0].Cells[i, 0];
cell.Value = 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
Aspose.Cells.Drawing.Shape listBox = book.Worksheets[0].Shapes.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);
SetLinkedCell(string, bool, bool)
Sets the range linked to the control’s value.
public void SetLinkedCell(string formula, bool isR1C1, bool isLocal)
Parameters
formula
string
The range linked to the control’s value.
isR1C1
bool
Whether the formula needs to be formatted as R1C1.
isLocal
bool
Whether the formula needs to be formatted by locale.
Examples
csharp
[C#]
//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
Aspose.Cells.Drawing.Shape scrollBar = book.Worksheets[0].Shapes.AddScrollBar(2, 0, 2, 0, 130, 30);
//Sets the range linked to the control's value.
scrollBar.SetLinkedCell("$A$12", false, true);
SetLockedProperty(ShapeLockType, bool)
Set the locked property.
public void SetLockedProperty(ShapeLockType type, bool value)
Parameters
type
ShapeLockType
The locked type.
value
bool
The value of the property.
Examples
csharp
[C#]
shape.SetLockedProperty(ShapeLockType.AdjustHandles, true);
ToFrontOrBack(int)
Brings the shape to the front or sends the shape to back.
public void ToFrontOrBack(int orders)
Parameters
orders
int
If it’s less than zero, sets the shape to back. If it’s greater than zero, brings the shape to front.
Examples
csharp
[C#]
shape.ToFrontOrBack(2);
//or shape.ToFrontOrBack(-1);
ToImage(Stream, ImageType)
Creates the shape image and saves it to a stream in the specified format.
public void ToImage(Stream stream, ImageType imageType)
Parameters
stream
Stream
The output stream.
imageType
ImageType
The type in which to save the image.
Examples
csharp
[C#]
MemoryStream imageStream = new MemoryStream();
shape.ToImage(imageStream, ImageType.Png);
Remarks
The following formats are supported: .bmp, .gif, .jpg, .jpeg, .tiff, .emf.
ToImage(string, ImageOrPrintOptions)
Saves the shape to a file.
public void ToImage(string imageFile, ImageOrPrintOptions options)
Parameters
imageFile
string
options
ImageOrPrintOptions
Examples
csharp
[C#]
ImageOrPrintOptions op = new ImageOrPrintOptions();
shape.ToImage("exmaple.png", op);
ToImage(Stream, ImageOrPrintOptions)
Saves the shape to a stream.
public void ToImage(Stream stream, ImageOrPrintOptions options)
Parameters
stream
Stream
options
ImageOrPrintOptions
Examples
csharp
[C#]
MemoryStream imageStream = new MemoryStream();
ImageOrPrintOptions op = new ImageOrPrintOptions();
shape.ToImage(imageStream, op);
UpdateSelectedValue()
Update the selected value by the value of the linked cell.
public void UpdateSelectedValue()
Examples
csharp
[C#]
Cell cell = null;
for (int i = 0; i< 10; ++i)
{
cell = book.Worksheets[0].Cells[i, 0];
cell.Value = 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
Aspose.Cells.Drawing.Shape listBox = book.Worksheets[0].Shapes.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.Worksheets[0].Cells[11, 0];
cell.Value = 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.Value = 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
}