TextBox Class

Encapsulates the object that represents a textbox in a spreadsheet.
Inheritance Hierarchy

Namespace:  Aspose.Cells.Drawing
Assembly:  Aspose.Cells (in Aspose.Cells.dll) Version: 22.5.0.0 (22.5.0)
Syntax
public class TextBox : Shape

The TextBox type exposes the following members.

Properties
  NameDescription
Public propertyCode exampleActiveXControl
Gets the ActiveX control.
(Inherited from Shape.)
Public propertyCode exampleActualLowerRightRow
Get the actual bottom row.
(Inherited from Shape.)
Public propertyCode exampleAlternativeText
Returns or sets the descriptive (alternative) text string of the Shape object.
(Inherited from Shape.)
Public propertyCode exampleAnchorType
Gets and set the shape anchor placeholder.
(Inherited from Shape.)
Public propertyCode exampleAutoShapeType
Gets and sets the auto shape type.
(Inherited from Shape.)
Public propertyCode exampleBottom
Represents the width of the shape's vertical offset from its lower bottom corner row, in unit of pixels.
(Inherited from Shape.)
Public propertyConnectionPoints Obsolete.
Get the connection points
(Inherited from Shape.)
Public propertyCode exampleControlData
Gets the data of control.
(Inherited from Shape.)
Public propertyCode exampleFill
Returns a FillFormat object that contains fill formatting properties for the specified shape.
(Inherited from Shape.)
Public propertyFillFormat Obsolete.
Returns a MsoFillFormat object that contains fill formatting properties for the specified shape.
(Inherited from Shape.)
Public propertyCode exampleFont
Represents the font of shape.
(Inherited from Shape.)
Public propertyFormat Obsolete.
Represents the setting of the shape's formatting.
(Inherited from Shape.)
Public propertyCode exampleFormatPicture
Gets and sets the options of the picture format.
(Inherited from Shape.)
Public propertyCode exampleGeometry
Gets the geometry
(Inherited from Shape.)
Public propertyCode exampleGlow
Represents a object that specifies glow effect for the chart element or shape.
(Inherited from Shape.)
Public propertyCode exampleGroup
Gets the group shape which contains this shape.
(Inherited from Shape.)
Public propertyCode exampleHasLine
Gets and sets the line border of the shape is visible.
(Inherited from Shape.)
Public propertyCode exampleHeight
Represents the height of shape, in unit of pixel.
(Inherited from Shape.)
Public propertyCode exampleHeightCM
Represents the height of the shape, in unit of centimeters.
(Inherited from Shape.)
Public propertyCode exampleHeightInch
Represents the height of the shape, in unit of inches.
(Inherited from Shape.)
Public propertyCode exampleHeightInShape
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..
(Inherited from Shape.)
Public propertyCode exampleHeightPt
Represents the height of the shape, in unit of points.
(Inherited from Shape.)
Public propertyCode exampleHeightScale
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;
(Inherited from Shape.)
Public propertyCode exampleHtmlText
Gets and sets the html string which contains data and some formats in this textbox.
(Inherited from Shape.)
Public propertyCode exampleHyperlink
Gets the hyperlink of the shape.
(Inherited from Shape.)
Public propertyCode exampleId
Gets the identifier of this shape.
(Inherited from Shape.)
Public propertyCode exampleInputRange
Gets or sets the worksheet range used to fill the specified combo box.
(Inherited from Shape.)
Public propertyCode exampleIsEquation
Indicates whether the shape only contains an equation.
(Inherited from Shape.)
Public propertyCode exampleIsFilled
Indicates whether the fill format is visible.
(Inherited from Shape.)
Public propertyCode exampleIsFlippedHorizontally
Gets and sets whether shape is horizontally flipped .
(Inherited from Shape.)
Public propertyCode exampleIsFlippedVertically
Gets and sets whether shape is vertically flipped .
(Inherited from Shape.)
Public propertyCode exampleIsGroup
Indicates whether the shape is a group.
(Inherited from Shape.)
Public propertyCode exampleIsHidden
Indicates whether the object is visible.
(Inherited from Shape.)
Public propertyIsInGroup
Indicates whether the shape is grouped.
(Inherited from Shape.)
Public propertyCode exampleIsLockAspectRatio
True means that don't allow changes in aspect ratio.
(Inherited from Shape.)
Public propertyCode exampleIsLocked
True if the object is locked, False if the object can be modified when the sheet is protected.
(Inherited from Shape.)
Public propertyCode exampleIsPrintable
True if the object is printable
(Inherited from Shape.)
Public propertyCode exampleIsRichText
Whether or not the text is rich text.
(Inherited from Shape.)
Public propertyCode exampleIsSmartArt
Indicates whether the shape is smart art.
(Inherited from Shape.)
Public propertyCode exampleIsTextWrapped
Gets and sets the text wrapped type of the shape which contains text.
(Inherited from Shape.)
Public propertyCode exampleIsWordArt
Indicates whether this shape is a word art.
(Inherited from Shape.)
Public propertyCode exampleLeft
Represents the horizontal offset of shape from its left column, in unit of pixels.
(Inherited from Shape.)
Public propertyCode exampleLeftCM
Represents the horizontal offset of shape from its left column, in unit of centimeters.
(Inherited from Shape.)
Public propertyCode exampleLeftInch
Represents the horizontal offset of shape from its left column, in unit of inches.
(Inherited from Shape.)
Public propertyCode exampleLeftInShape
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.
(Inherited from Shape.)
Public propertyCode exampleLeftToCorner
Gets and sets the horizonal offset of shape from worksheet left border.
(Inherited from Shape.)
Public propertyCode exampleLine
Gets line style
(Inherited from Shape.)
Public propertyLineFormat Obsolete.
Returns a MsoLineFormat object that contains line formatting properties for the specified shape.
(Inherited from Shape.)
Public propertyCode exampleLinkedCell
Gets or sets the worksheet range linked to the control's value.
(Inherited from Shape.)
Public propertyCode exampleLowerDeltaX
Gets or sets the shape's horizontal offset from its lower right corner column.
Remarks
The range of value is 0 to 1024.
(Inherited from Shape.)
Public propertyCode exampleLowerDeltaY
Gets or sets the shape's vertical offset from its lower right corner row.
Remarks
The range of value is 0 to 256.
(Inherited from Shape.)
Public propertyCode exampleLowerRightColumn
Represents lower right corner column index.
(Inherited from Shape.)
Public propertyCode exampleLowerRightRow
Represents lower right corner row index.
(Inherited from Shape.)
Public propertyCode exampleMacroName
Gets and sets the name of macro.
(Inherited from Shape.)
Public propertyCode exampleMsoDrawingType
Gets mso drawing type.
(Inherited from Shape.)
Public propertyCode exampleName
Gets and sets the name of the shape.
(Inherited from Shape.)
Public propertyCode examplePaths
Gets the paths of a custom geometric shape.
(Inherited from Shape.)
Public propertyCode examplePlacement
Represents the way the drawing object is attached to the cells below it. The property controls the placement of an object on a worksheet.
(Inherited from Shape.)
Public propertyCode exampleReflection
Represents a object that specifies reflection effect for the chart element or shape.
(Inherited from Shape.)
Public propertyCode exampleRelativeToOriginalPictureSize
Indicates whether shape is relative to original picture size.
(Inherited from Shape.)
Public propertyCode exampleRight
Represents the width of the shape's horizontal offset from its lower right corner column, in unit of pixels.
(Inherited from Shape.)
Public propertyCode exampleRotationAngle
Gets and sets the rotation of the shape.
(Inherited from Shape.)
Public propertyCode exampleShadowEffect
Represents a object that specifies shadow effect for the chart element or shape.
(Inherited from Shape.)
Public propertyCode exampleSoftEdges
Gets and sets the radius of blur to apply to the edges, in unit of points.
(Inherited from Shape.)
Public propertyCode exampleSpid
Specifies an optional string that an application can use to Identify the particular shape.
(Inherited from Shape.)
Public propertyCode exampleSpt
Specifies an optional number that an application can use to associate the particular shape with a defined shape type.
(Inherited from Shape.)
Public propertyCode exampleText
Represents the string in this TextBox object.
(Inherited from Shape.)
Public propertyCode exampleTextBody
Gets and sets the setting of the shape's text.
(Inherited from Shape.)
Public propertyCode exampleTextDirection
Gets/Sets the direction of the text flow for this object.
(Inherited from Shape.)
Public propertyCode exampleTextEffect
Returns a TextEffectFormat object that contains text-effect formatting properties for the specified shape. Applies to Shape objects that represent WordArt.
(Inherited from Shape.)
Public propertyTextFrame Obsolete.
Returns a TextFrame object that contains the alignment and anchoring properties for the specified shape.
(Inherited from Shape.)
Public propertyCode exampleTextHorizontalAlignment
Gets and sets the text horizontal alignment type of the shape.
(Inherited from Shape.)
Public propertyCode exampleTextHorizontalOverflow
Gets and sets the text horizontal overflow type of the shape which contains text.
(Inherited from Shape.)
Public propertyCode exampleTextOptions
Represents the text options of the shape.
(Inherited from Shape.)
Public propertyCode exampleTextOrientationType
Gets and sets the text orientation type of the shape.
(Inherited from Shape.)
Public propertyCode exampleTextShapeType
Gets and sets the preset text shape type.
(Inherited from Shape.)
Public propertyCode exampleTextVerticalAlignment
Gets and sets the text vertical alignment type of the shape.
(Inherited from Shape.)
Public propertyCode exampleTextVerticalOverflow
Gets and sets the text vertical overflow type of the shape which contains text.
(Inherited from Shape.)
Public propertyCode exampleThreeDFormat
Gets and sets 3d format of the shape.
(Inherited from Shape.)
Public propertyCode exampleTitle
Specifies the title (caption) of the current shape object.
(Inherited from Shape.)
Public propertyCode exampleTop
Represents the vertical offset of shape from its top row, in unit of pixels.
(Inherited from Shape.)
Public propertyCode exampleTopCM
Represents the vertical offset of shape from its top row, in unit of centimeters.
(Inherited from Shape.)
Public propertyCode exampleTopInch
Represents the vertical offset of shape from its top row, in unit of inches.
(Inherited from Shape.)
Public propertyCode exampleTopInShape
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.
(Inherited from Shape.)
Public propertyCode exampleTopToCorner
Gets and sets the vertical offset of shape from worksheet top border, in unit of pixels.
(Inherited from Shape.)
Public propertyCode exampleType
Gets the auto shape type.
(Inherited from Shape.)
Public propertyCode exampleUpperDeltaX
Gets or sets the shape's horizontal offset from its upper left corner column.
Remarks
The range of value is 0 to 1024.
(Inherited from Shape.)
Public propertyCode exampleUpperDeltaY
Gets or sets the shape's vertical offset from its upper left corner row.
Remarks
The range of value is 0 to 256.
(Inherited from Shape.)
Public propertyCode exampleUpperLeftColumn
Represents upper left corner column index.
(Inherited from Shape.)
Public propertyCode exampleUpperLeftRow
Represents upper left corner row index.
(Inherited from Shape.)
Public propertyCode exampleWidth
Represents the width of shape, in unit of pixels.
(Inherited from Shape.)
Public propertyCode exampleWidthCM
Represents the width of the shape, in unit of centimeters.
(Inherited from Shape.)
Public propertyCode exampleWidthInch
Represents the width of the shape, in unit of inch.
(Inherited from Shape.)
Public propertyCode exampleWidthInShape
Represents the width of the shape, in unit of 1/4000 of the parent shape.
(Inherited from Shape.)
Public propertyCode exampleWidthPt
Represents the width of the shape, in unit of point.
(Inherited from Shape.)
Public propertyCode exampleWidthScale
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;
(Inherited from Shape.)
Public propertyCode exampleWorksheet
Gets the Worksheet object which contains this shape.
(Inherited from Shape.)
Public propertyCode exampleX
Gets and sets the horizontal offset of shape from worksheet left border,in unit of pixels.
(Inherited from Shape.)
Public propertyCode exampleY
Gets and sets the vertical offset of shape from worksheet top border,in unit of pixels.
(Inherited from Shape.)
Public propertyCode exampleZOrderPosition
Returns the position of a shape in the z-order.
(Inherited from Shape.)
Methods
  NameDescription
Public methodCode exampleAddHyperlink
Adds a hyperlink to the shape.
(Inherited from Shape.)
Public methodCode exampleAlignTopRightCorner
Moves the picture to the top-right corner.
(Inherited from Shape.)
Public methodCode exampleCalculateTextSize
Recalculate the text area
(Inherited from Shape.)
Public methodCode exampleCharacters
Returns a Characters object that represents a range of characters within the text.
(Inherited from Shape.)
Public methodEquals (Inherited from Object.)
Protected methodFinalize (Inherited from Object.)
Public methodFormatCharacters(Int32, Int32, Font) Obsolete.
Formats some characters with the font setting.
(Inherited from Shape.)
Public methodFormatCharacters(Int32, Int32, Font, StyleFlag)
Formats some characters with the font setting.
(Inherited from Shape.)
Public methodCode exampleGetCharacters
Returns all Characters objects that represents a range of characters within the text .
(Inherited from Shape.)
Public methodCode exampleGetConnectionPoints
Get the connection points
(Inherited from Shape.)
Public methodGetHashCode (Inherited from Object.)
Public methodCode exampleGetInputRange
Gets the range used to fill the control.
(Inherited from Shape.)
Public methodCode exampleGetLinkedCell
Gets the range linked to the control's value.
(Inherited from Shape.)
Public methodCode exampleGetLockedProperty
Gets the value of locked property.
(Inherited from Shape.)
Public methodCode exampleGetResultOfSmartArt
Converting smart art to grouped shapes.
(Inherited from Shape.)
Public methodGetType (Inherited from Object.)
Public methodCode exampleIsSameSetting
Returns whether the shape is same.
(Inherited from Shape.)
Protected methodMemberwiseClone (Inherited from Object.)
Public methodCode exampleMoveToRange
Moves the shape to a specified range.
(Inherited from Shape.)
Public methodCode exampleRemoveActiveXControl
Remove activeX control.
(Inherited from Shape.)
Public methodCode exampleRemoveHyperlink
Remove the hyperlink of the shape.
(Inherited from Shape.)
Public methodCode exampleSetInputRange
Sets the range used to fill the control.
(Inherited from Shape.)
Public methodCode exampleSetLinkedCell
Sets the range linked to the control's value.
(Inherited from Shape.)
Public methodCode exampleSetLockedProperty
Set the locked property.
(Inherited from Shape.)
Public methodCode exampleToFrontOrBack
Brings the shape to the front or sends the shape to back.
(Inherited from Shape.)
Public methodCode exampleToImage(ImageOrPrintOptions)
Returns the bitmap object of the shape .
(Inherited from Shape.)
Public methodCode exampleToImage(Stream, ImageOrPrintOptions)
Saves the shape to a stream.
(Inherited from Shape.)
Public methodCode exampleToImage(Stream, ImageFormat)
Creates the shape image and saves it to a stream in the specified format.
(Inherited from Shape.)
Public methodCode exampleToImage(String, ImageOrPrintOptions)
Saves the shape to a file.
(Inherited from Shape.)
Public methodToString (Inherited from Object.)
Public methodCode exampleUpdateSelectedValue
Update the selected value by the value of the linked cell.
(Inherited from Shape.)
Examples
[C#]

//Instantiate a new Workbook.
Workbook workbook = new Workbook();
//Get the first worksheet in the book.
Worksheet worksheet = workbook.Worksheets[0];
//Add a new textbox to the collection.
int textboxIndex = worksheet.TextBoxes.Add(2, 1, 160, 200);
//Get the textbox object.
Aspose.Cells.Drawing.TextBox textbox0 = worksheet.TextBoxes[textboxIndex];
//Fill the text.
textbox0.Text = "ASPOSE______The .NET and JAVA Component Publisher!";
//Set the textbox to adjust it according to its contents.
textbox0.TextBody.TextAlignment.AutoSize = true;
//Set the placement.
textbox0.Placement = PlacementType.FreeFloating;
//Set the font color.
textbox0.Font.Color = Color.Blue;
//Set the font to bold.
textbox0.Font.IsBold = true;
//Set the font size.
textbox0.Font.Size = 14;
//Set font attribute to italic.
textbox0.Font.IsItalic = true;
//Add a hyperlink to the textbox.
textbox0.AddHyperlink("http://www.aspose.com/");
//Get the filformat of the textbox.
FillFormat fillformat = textbox0.Fill;
//Set the fillcolor.
fillformat.SolidFill.Color = Color.Silver;
//Get the lineformat type of the textbox.
LineFormat lineformat = textbox0.Line;
//Set the line style.
lineformat.CompoundType = MsoLineStyle.ThinThick;
//Set the line weight.
lineformat.Weight = 6;
//Set the dash style to squaredot.
lineformat.DashStyle = MsoLineDashStyle.SquareDot;
//Add another textbox.
textboxIndex = worksheet.TextBoxes.Add(15, 4, 85, 120);
//Get the second textbox.
Aspose.Cells.Drawing.TextBox textbox1 = worksheet.TextBoxes[textboxIndex];
//Input some text to it.
textbox1.Text = "This is another simple text box";
//Set the placement type as the textbox will move and
//resize with cells.
textbox1.Placement = PlacementType.MoveAndSize;
//Save the excel file.
workbook.Save("tsttextboxes.xlsx");

[Visual Basic]

'Instantiate a new Workbook.
Dim workbook As Workbook = New Workbook()
'Get the first worksheet in the book.
Dim worksheet As Worksheet = workbook.Worksheets(0)
'Add a new textbox to the collection.
Dim textboxIndex As Integer = worksheet.TextBoxes.Add(2, 1, 160, 200)
'Get the textbox object.
Dim textbox0 As Aspose.Cells.Drawing.TextBox = worksheet.TextBoxes(textboxIndex)
'Fill the text.
textbox0.Text = "ASPOSE______The .NET and JAVA Component Publisher!"
'Set the textbox to adjust it according to its contents.
textbox0.TextBody.TextAlignment.AutoSize = True
'Set the placement.
textbox0.Placement = PlacementType.FreeFloating
'Set the font color.
textbox0.Font.Color = Color.Blue
'Set the font to bold.
textbox0.Font.IsBold = True
'Set the font size.
textbox0.Font.Size = 14
'Set font attribute to italic.
textbox0.Font.IsItalic = True
'Add a hyperlink to the textbox.
textbox0.AddHyperlink("http://www.aspose.com/")
'Get the filformat of the textbox.
Dim fillformat As FillFormat = textbox0.Fill
'Set the fillcolor.
fillformat.SolidFill.Color = Color.Silver
'Get the lineformat type of the textbox.
Dim lineformat As LineFormat = textbox0.Line
'Set the line style.
lineformat.CompoundType = MsoLineStyle.ThinThick
'Set the line weight.
lineformat.Weight = 6
'Set the dash style to squaredot.
lineformat.DashStyle = MsoLineDashStyle.SquareDot
'Add another textbox.
textboxIndex = worksheet.TextBoxes.Add(15, 4, 85, 120)
'Get the second textbox.
Dim textbox1 As Aspose.Cells.Drawing.TextBox = worksheet.TextBoxes(textboxIndex)
'Input some text to it.
textbox1.Text = "This is another simple text box"
'Set the placement type as the textbox will move and
'resize with cells.
textbox1.Placement = PlacementType.MoveAndSize
'Save the excel file.
workbook.Save("tsttextboxes.xlsx")
See Also