Interface ITextBox
This interface represents TextBox form control.
Namespace: Syncfusion.XlsIO
Assembly: Syncfusion.XlsIO.NET.dll
Syntax
public interface ITextBox : IParentApplication
Properties
HAlignment
Horizontal alignment of the text.
Declaration
ExcelCommentHAlign HAlignment { get; set; }
Property Value
Type |
---|
ExcelCommentHAlign |
Examples
By default Left is set to HAlignment
. Here for example, we set Center
to HAlignment
property.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet worksheet = workbook.Worksheets[0];
//Add textbox
ITextBox textbox = worksheet.TextBoxes.AddTextBox(5, 5, 40, 100);
//Set text
textbox.Text = "Text";
//Set alignment
textbox.HAlignment = ExcelCommentHAlign.Left;
//Save and dispose
workbook.SaveAs("Shapes.xlsx");
workbook.Close();
}
IsTextLocked
Indicates whether comment text is locked.
Declaration
bool IsTextLocked { get; set; }
Property Value
Type |
---|
System.Boolean |
Examples
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet worksheet = workbook.Worksheets[0];
//Add textbox
ITextBox textbox = worksheet.TextBoxes.AddTextBox(5, 5, 40, 100);
//Set text
textbox.Text = "Text";
//Set locked
textbox.IsTextLocked = false;
//Set sheet protection
worksheet.Protect("", ExcelSheetProtection.All);
//Save and dispose
workbook.SaveAs("Shapes.xlsx");
workbook.Close();
}
RichText
Text of the comment. Read-only.
Declaration
IRichTextString RichText { get; set; }
Property Value
Type |
---|
IRichTextString |
Examples
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet worksheet = workbook.Worksheets[0];
//Add textbox
ITextBox textbox = worksheet.TextBoxes.AddTextBox(5, 5, 20, 100);
//Set rich text
IRichTextString richText = textbox.RichText;
//Set font
IFont font = workbook.CreateFont();
font.Color = ExcelKnownColors.Red;
//Set text
richText.Text = "Text";
//Apply format
richText.SetFont(0, 3, font);
//Save and dispose
workbook.SaveAs("Shapes.xlsx");
workbook.Close();
}
Text
Text of the comment.
Declaration
string Text { get; set; }
Property Value
Type |
---|
System.String |
Examples
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet worksheet = workbook.Worksheets[0];
//Add textbox
ITextBox textbox = worksheet.TextBoxes.AddTextBox(5, 5, 40, 100);
//Set text
textbox.Text = "Text";
//Set alignment
textbox.HAlignment = ExcelCommentHAlign.Center;
textbox.VAlignment = ExcelCommentVAlign.Center;
//Save and dispose
workbook.SaveAs("Shapes.xlsx");
workbook.Close();
}
TextRotation
Text rotation.
Declaration
ExcelTextRotation TextRotation { get; set; }
Property Value
Type |
---|
ExcelTextRotation |
Examples
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet worksheet = workbook.Worksheets[0];
//Add textbox
ITextBox textbox = worksheet.TextBoxes.AddTextBox(5, 5, 200, 100);
//Set text
textbox.Text = "Text";
//Set rotation
textbox.TextRotation = ExcelTextRotation.Clockwise;
//Save and dispose
workbook.SaveAs("Shapes.xlsx");
workbook.Close();
}
VAlignment
Vertical alignment of the text.
Declaration
ExcelCommentVAlign VAlignment { get; set; }
Property Value
Type |
---|
ExcelCommentVAlign |
Examples
By default Top is set to VAlignment
. Here for example, we set Center
to HAlignment
property.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet worksheet = workbook.Worksheets[0];
//Add textbox
ITextBox textbox = worksheet.TextBoxes.AddTextBox(5, 5, 200, 100);
//Set text
textbox.Text = "Text";
//Set alignment
textbox.VAlignment = ExcelCommentVAlign.Center;
//Save and dispose
workbook.SaveAs("Shapes.xlsx");
workbook.Close();
}