Aspose::Cells::Drawing::TextBox class

TextBox class

Encapsulates the object that represents a textbox in a spreadsheet.

class TextBox : public Aspose::Cells::Drawing::Shape

Methods

MethodDescription
AddHyperlink(const U16String& address)Adds a hyperlink to the shape.
AddHyperlink(const char16_t* address)Adds a hyperlink to the shape.
AlignTopRightCorner(int32_t topRow, int32_t rightColumn)Moves the picture to the top-right corner.
CalculateTextSize()Recalculate the text area.
Characters(int32_t startIndex, int32_t length)Returns a Characters object that represents a range of characters within the text.
FormatCharacters(int32_t startIndex, int32_t length, const Aspose::Cells::Font& font, const StyleFlag& flag)Formats some characters with the font setting.
GetActiveXControl()Gets the ActiveX control.
GetActualBox()Get the actual position and size of the shape (after applying rotation, flip, etc.)
GetActualLowerRightRow()Get the actual bottom row.
GetAlternativeText()Returns or sets the descriptive (alternative) text string of the Shape object.
GetAnchorType()Gets and set the shape anchor placeholder.
GetAutoShapeType()Gets and sets the auto shape type.
GetBottom()Represents the width of the shape’s vertical offset from its lower bottom corner row, in unit of pixels.
GetControlData()Gets the data of control.
GetCreateId(UUID& uuid)Gets and sets create id for this shape.
GetEquationParagraph(int32_t index)Get the specified math paragraph from the TextBody property of the TextBox object. Notice: (1) Returns NULL when the index is out of bounds or not found. (2) Also returns NULL if the specified index position is not a math paragraph.
GetEquationParagraph()Gets the first math paragraph from the TextBody property of the TextBox object.
GetFill()Returns a FillFormat object that contains fill formatting properties for the specified shape.
GetFont()Represents the font of shape.
GetFormatPicture()Gets and sets the options of the picture format.
GetGeometry()Gets the geometry.
GetGlow()Represents a GlowEffect object that specifies glow effect for the chart element or shape.
GetGroup()Gets the group shape which contains this shape.
GetHasLine()Gets and sets the line border of the shape is visible.
GetHeight()Represents the height of shape, in unit of pixel.
GetHeightCM()Represents the height of the shape, in unit of centimeters.
GetHeightInch()Represents the height of the shape, in unit of inches.
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..
GetHeightPt()Represents the height of the shape, in unit of points.
GetHeightScale()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;.
GetHtmlText()Gets and sets the html string which contains data and some formats in this textbox.
GetHyperlink()Gets the hyperlink of the shape.
GetId()Gets the identifier of this shape.
GetInputRange()Gets or sets the worksheet range used to fill the specified combo box.
GetInputRange(bool isR1C1, bool isLocal)Gets the range used to fill the control.
GetLeft()Represents the horizontal offset of shape from its left column, in unit of pixels.
GetLeftCM()Represents the horizontal offset of shape from its left column, in unit of centimeters.
GetLeftInch()Represents the horizontal offset of shape from its left column, in unit of inches.
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.
GetLeftToCorner()Gets and sets the horizonal offset of shape from worksheet left border.
GetLine()Gets line style.
GetLinkedCell()Gets or sets the worksheet range linked to the control’s value.
GetLinkedCell(bool isR1C1, bool isLocal)Gets the range linked to the control’s value.
GetLockedProperty(ShapeLockType type)Gets the value of locked property.
GetLowerDeltaX()Gets or sets the shape’s horizontal offset from its lower right corner column.
GetLowerDeltaY()Gets or sets the shape’s vertical offset from its lower right corner row.
GetLowerRightColumn()Represents lower right corner column index.
GetLowerRightRow()Represents lower right corner row index.
GetMacroName()Gets and sets the name of macro.
GetMsoDrawingType()Gets mso drawing type.
GetName()Gets and sets the name of the shape.
GetPaths()Gets the paths of a custom geometric shape.
GetPlacement()Represents the way the drawing object is attached to the cells below it. The property controls the placement of an object on a worksheet.
GetReflection()Represents a ReflectionEffect object that specifies reflection effect for the chart element or shape.
GetRelativeToOriginalPictureSize()Indicates whether shape is relative to original picture size.
GetResultOfSmartArt()Converting smart art to grouped shapes.
GetRichFormattings()Returns all Characters objects that represents a range of characters within the text .
GetRight()Represents the width of the shape’s horizontal offset from its lower right corner column, in unit of pixels.
GetRotationAngle()Gets and sets the rotation of the shape.
GetShadowEffect()Represents a Drawing.ShadowEffect object that specifies shadow effect for the chart element or shape.
GetSoftEdges()Gets and sets the radius of blur to apply to the edges, in unit of points.
GetSpid()Specifies an optional string that an application can use to Identify the particular shape.
GetSpt()Specifies an optional number that an application can use to associate the particular shape with a defined shape type.
GetText()Represents the string in this TextBox object.
GetTextBody()Gets and sets the setting of the shape’s text.
GetTextDirection()Gets/Sets the direction of the text flow for this object.
GetTextEffect()Returns a TextEffectFormat object that contains text-effect formatting properties for the specified shape. Applies to Shape objects that represent WordArt.
GetTextHorizontalAlignment()Gets and sets the text horizontal alignment type of the shape.
GetTextHorizontalOverflow()Gets and sets the text horizontal overflow type of the shape which contains text.
GetTextOptions()Represents the text options of the shape.
GetTextOrientationType()Gets and sets the text orientation type of the shape.
GetTextShapeType()Gets and sets the preset text shape type.
GetTextVerticalAlignment()Gets and sets the text vertical alignment type of the shape.
GetTextVerticalOverflow()Gets and sets the text vertical overflow type of the shape which contains text.
GetThreeDFormat()Gets and sets 3d format of the shape.
GetTitle()Specifies the title (caption) of the current shape object.
GetTop()Represents the vertical offset of shape from its top row, in unit of pixels.
GetTopCM()Represents the vertical offset of shape from its top row, in unit of centimeters.
GetTopInch()Represents the vertical offset of shape from its top row, in unit of inches.
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.
GetTopToCorner()Gets and sets the vertical offset of shape from worksheet top border, in unit of pixels.
GetType()Gets the auto shape type.
GetUpperDeltaX()Gets or sets the shape’s horizontal offset from its upper left corner column.
GetUpperDeltaY()Gets or sets the shape’s vertical offset from its upper left corner row.
GetUpperLeftColumn()Represents upper left corner column index.
GetUpperLeftRow()Represents upper left corner row index.
GetWidth()Represents the width of shape, in unit of pixels.
GetWidthCM()Represents the width of the shape, in unit of centimeters.
GetWidthInch()Represents the width of the shape, in unit of inch.
GetWidthInShape()Represents the width of the shape, in unit of 1/4000 of the parent shape.
GetWidthPt()Represents the width of the shape, in unit of point.
GetWidthScale()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;.
GetWorksheet()Gets the Worksheet object which contains this shape.
GetX()Gets and sets the horizontal offset of shape from worksheet left border,in unit of pixels.
GetY()Gets and sets the vertical offset of shape from worksheet top border,in unit of pixels.
GetZOrderPosition()Returns the position of a shape in the z-order.
IsEquation()Indicates whether the shape only contains an equation.
IsFilled()Indicates whether the fill format is visible.
IsFlippedHorizontally()Gets and sets whether shape is horizontally flipped .
IsFlippedVertically()Gets and sets whether shape is vertically flipped .
IsGroup()Indicates whether the shape is a group.
IsHidden()Indicates whether the object is visible.
IsInGroup()Indicates whether the shape is grouped.
IsLockAspectRatio()True means that don’t allow changes in aspect ratio.
IsLocked()True if the object is locked, False if the object can be modified when the sheet is protected.
IsNull() constChecks whether the implementation object is nullptr.
IsPrintable()True if the object is printable.
IsRichText()Whether or not the text is rich text.
IsSmartArt()Indicates whether the shape is smart art.
IsTextWrapped()Gets and sets the text wrapped type of the shape which contains text.
IsWordArt()Indicates whether this shape is a word art.
MoveToRange(int32_t upperLeftRow, int32_t upperLeftColumn, int32_t lowerRightRow, int32_t lowerRightColumn)Moves the shape to a specified range.
explicit operator bool() constoperator bool()
operator=(const TextBox& src)operator=
operator=(const Shape& src)operator=
RemoveActiveXControl()Remove activeX control.
RemoveHyperlink()Remove the hyperlink of the shape.
SetAlternativeText(const U16String& value)Returns or sets the descriptive (alternative) text string of the Shape object.
SetAlternativeText(const char16_t* value)Returns or sets the descriptive (alternative) text string of the Shape object.
SetAnchorType(ShapeAnchorType value)Gets and set the shape anchor placeholder.
SetAutoShapeType(AutoShapeType value)Gets and sets the auto shape type.
SetBottom(int32_t value)Represents the width of the shape’s vertical offset from its lower bottom corner row, in unit of pixels.
SetCreateId(const UUID& value)Gets and sets create id for this shape.
SetFont(const Aspose::Cells::Font& value)Represents the font of shape.
SetHasLine(bool value)Gets and sets the line border of the shape is visible.
SetHeight(int32_t value)Represents the height of shape, in unit of pixel.
SetHeightCM(double value)Represents the height of the shape, in unit of centimeters.
SetHeightInch(double value)Represents the height of the shape, in unit of inches.
SetHeightInShape(int32_t 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..
SetHeightPt(double value)Represents the height of the shape, in unit of points.
SetHeightScale(int32_t value)Gets and sets the height scale,in unit of percent of the original picture height. If the shape is not picture ,the HeightScale property only returns 100;.
SetHtmlText(const U16String& value)Gets and sets the html string which contains data and some formats in this textbox.
SetHtmlText(const char16_t* value)Gets and sets the html string which contains data and some formats in this textbox.
SetInputRange(const U16String& value)Gets or sets the worksheet range used to fill the specified combo box.
SetInputRange(const char16_t* value)Gets or sets the worksheet range used to fill the specified combo box.
SetInputRange(const U16String& formula, bool isR1C1, bool isLocal)Sets the range used to fill the control.
SetInputRange(const char16_t* formula, bool isR1C1, bool isLocal)Sets the range used to fill the control.
SetIsFilled(bool value)Indicates whether the fill format is visible.
SetIsFlippedHorizontally(bool value)Gets and sets whether shape is horizontally flipped .
SetIsFlippedVertically(bool value)Gets and sets whether shape is vertically flipped .
SetIsHidden(bool value)Indicates whether the object is visible.
SetIsLockAspectRatio(bool value)True means that don’t allow changes in aspect ratio.
SetIsLocked(bool value)True if the object is locked, False if the object can be modified when the sheet is protected.
SetIsPrintable(bool value)True if the object is printable.
SetIsTextWrapped(bool value)Gets and sets the text wrapped type of the shape which contains text.
SetLeft(int32_t value)Represents the horizontal offset of shape from its left column, in unit of pixels.
SetLeftCM(double value)Represents the horizontal offset of shape from its left column, in unit of centimeters.
SetLeftInch(double value)Represents the horizontal offset of shape from its left column, in unit of inches.
SetLeftInShape(int32_t 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.
SetLeftToCorner(int32_t value)Gets and sets the horizonal offset of shape from worksheet left border.
SetLinkedCell(const U16String& value)Gets or sets the worksheet range linked to the control’s value.
SetLinkedCell(const char16_t* value)Gets or sets the worksheet range linked to the control’s value.
SetLinkedCell(const U16String& formula, bool isR1C1, bool isLocal)Sets the range linked to the control’s value.
SetLinkedCell(const char16_t* formula, bool isR1C1, bool isLocal)Sets the range linked to the control’s value.
SetLockedProperty(ShapeLockType type, bool value)Set the locked property.
SetLowerDeltaX(int32_t value)Gets or sets the shape’s horizontal offset from its lower right corner column.
SetLowerDeltaY(int32_t value)Gets or sets the shape’s vertical offset from its lower right corner row.
SetLowerRightColumn(int32_t value)Represents lower right corner column index.
SetLowerRightRow(int32_t value)Represents lower right corner row index.
SetMacroName(const U16String& value)Gets and sets the name of macro.
SetMacroName(const char16_t* value)Gets and sets the name of macro.
SetName(const U16String& value)Gets and sets the name of the shape.
SetName(const char16_t* value)Gets and sets the name of the shape.
SetPlacement(PlacementType value)Represents the way the drawing object is attached to the cells below it. The property controls the placement of an object on a worksheet.
SetRelativeToOriginalPictureSize(bool value)Indicates whether shape is relative to original picture size.
SetRight(int32_t value)Represents the width of the shape’s horizontal offset from its lower right corner column, in unit of pixels.
SetRotationAngle(double value)Gets and sets the rotation of the shape.
SetSoftEdges(double value)Gets and sets the radius of blur to apply to the edges, in unit of points.
SetText(const U16String& value)Represents the string in this TextBox object.
SetText(const char16_t* value)Represents the string in this TextBox object.
SetTextDirection(TextDirectionType value)Gets/Sets the direction of the text flow for this object.
SetTextHorizontalAlignment(TextAlignmentType value)Gets and sets the text horizontal alignment type of the shape.
SetTextHorizontalOverflow(TextOverflowType value)Gets and sets the text horizontal overflow type of the shape which contains text.
SetTextOptions(const TextOptions& value)Represents the text options of the shape.
SetTextOrientationType(TextOrientationType value)Gets and sets the text orientation type of the shape.
SetTextShapeType(AutoShapeType value)Gets and sets the preset text shape type.
SetTextVerticalAlignment(TextAlignmentType value)Gets and sets the text vertical alignment type of the shape.
SetTextVerticalOverflow(TextOverflowType value)Gets and sets the text vertical overflow type of the shape which contains text.
SetTitle(const U16String& value)Specifies the title (caption) of the current shape object.
SetTitle(const char16_t* value)Specifies the title (caption) of the current shape object.
SetTop(int32_t value)Represents the vertical offset of shape from its top row, in unit of pixels.
SetTopCM(double value)Represents the vertical offset of shape from its top row, in unit of centimeters.
SetTopInch(double value)Represents the vertical offset of shape from its top row, in unit of inches.
SetTopInShape(int32_t 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.
SetTopToCorner(int32_t value)Gets and sets the vertical offset of shape from worksheet top border, in unit of pixels.
SetUpperDeltaX(int32_t value)Gets or sets the shape’s horizontal offset from its upper left corner column.
SetUpperDeltaY(int32_t value)Gets or sets the shape’s vertical offset from its upper left corner row.
SetUpperLeftColumn(int32_t value)Represents upper left corner column index.
SetUpperLeftRow(int32_t value)Represents upper left corner row index.
SetWidth(int32_t value)Represents the width of shape, in unit of pixels.
SetWidthCM(double value)Represents the width of the shape, in unit of centimeters.
SetWidthInch(double value)Represents the width of the shape, in unit of inch.
SetWidthInShape(int32_t value)Represents the width of the shape, in unit of 1/4000 of the parent shape.
SetWidthPt(double value)Represents the width of the shape, in unit of point.
SetWidthScale(int32_t value)Gets and sets the width scale, in unit of percent of the original picture width. If the shape is not picture ,the WidthScale property only returns 100;.
SetX(int32_t value)Gets and sets the horizontal offset of shape from worksheet left border,in unit of pixels.
SetY(int32_t value)Gets and sets the vertical offset of shape from worksheet top border,in unit of pixels.
SetZOrderPosition(int32_t value)Returns the position of a shape in the z-order.
Shape(Shape_Impl* impl)Constructs from an implementation object.
Shape(const Shape& src)Copy constructor.
TextBox(TextBox_Impl* impl)Constructs from an implementation object.
TextBox(const TextBox& src)Copy constructor.
TextBox(const Shape& src)Constructs from a parent object.
ToFrontOrBack(int32_t orders)Brings the shape to the front or sends the shape to back.
ToImage(const Vector <uint8_t>& stream, Aspose::Cells::Drawing::ImageType imageType)Creates the shape image and saves it to a stream in the specified format.
ToImage(const U16String& imageFile, const ImageOrPrintOptions& options)Saves the shape to a file.
ToImage(const char16_t* imageFile, const ImageOrPrintOptions& options)Saves the shape to a file.
ToImage(const ImageOrPrintOptions& options)Saves the shape to a stream.
UpdateSelectedValue()Update the selected value by the value of the linked cell.
~Shape()Destructor.
~TextBox()Destructor.

Fields

FieldDescription
_implThe implementation object.

Examples

Aspose::Cells::Startup();
//Instantiate a new Workbook.
Workbook workbook;
//Get the first worksheet in the book.
Worksheet worksheet = workbook.GetWorksheets().Get(0);
//Add a new textbox to the collection.
int textboxIndex = worksheet.GetTextBoxes().Add(2, 1, 160, 200);
//Get the textbox object.
TextBox textbox0 = worksheet.GetTextBoxes().Get(textboxIndex);
//Fill the text.
textbox0.SetText(u"ASPOSE______The .NET and JAVA Component Publisher!");
//Set the textbox to adjust it according to its contents.
textbox0.GetTextBody().GetTextAlignment().SetAutoSize(true);
//Set the placement.
textbox0.SetPlacement(PlacementType::FreeFloating);
//Set the font color.
textbox0.GetFont().SetColor(Color{ 0xff, 0, 0, 0xff });//Blue
//Set the font to bold.
textbox0.GetFont().SetIsBold(true);
//Set the font size.
textbox0.GetFont().SetSize(14);
//Set font attribute to italic.
textbox0.GetFont().SetIsItalic(true);
//Add a hyperlink to the textbox.
textbox0.AddHyperlink(u"http://www.aspose.com/");
//Get the filformat of the textbox.
FillFormat fillformat = textbox0.GetFill();
//Set the fillcolor.
fillformat.GetSolidFill().SetColor(Color{ 0xff, 0xc0, 0xc0, 0xc0 });//Silver
//Get the lineformat type of the textbox.
LineFormat lineformat = textbox0.GetLine();
//Set the line style.
lineformat.SetCompoundType(MsoLineStyle::ThinThick);
//Set the line weight.
lineformat.SetWeight(6);
//Set the dash style to squaredot.
lineformat.SetDashStyle(MsoLineDashStyle::SquareDot);
//Add another textbox.
textboxIndex = worksheet.GetTextBoxes().Add(15, 4, 85, 120);
//Get the second textbox.
TextBox textbox1 = worksheet.GetTextBoxes().Get(textboxIndex);
//Input some text to it.
textbox1.SetText(u"This is another simple text box");
//Set the placement type as the textbox will move and
//resize with cells.
textbox1.SetPlacement(PlacementType::MoveAndSize);
//Save the excel file.
workbook.Save(u"tsttextboxes.xlsx");

Aspose::Cells::Cleanup();

See Also