Interface ITextBoxes
This interface represents TextBoxes collection inside single worksheet.
Namespace: Syncfusion.XlsIO
Assembly: Syncfusion.XlsIO.UWP.dll
Syntax
public interface ITextBoxes
Properties
Count
Returns number of items in the collection.
Declaration
int Count { get; }
Property Value
Type |
---|
System.Int32 |
Examples
The following code illustrates how to access the Count
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
ITextBoxShape textbox1 = worksheet.TextBoxes.AddTextBox(1, 1, 20, 100);
ITextBoxShape textbox2 = worksheet.TextBoxes.AddTextBox(5, 5, 20, 100);
//Set name
textbox1.Name = "TextBox1";
textbox2.Name = "TextBox2";
//Get count
Console.Write(worksheet.TextBoxes.Count);
//Save and dispose
workbook.SaveAs("Shapes.xlsx");
workbook.Close();
Console.ReadKey();
}
//Output will be
//2
Item[Int32]
Returns single ITextBoxShape from the ITextBoxes collection.
Declaration
ITextBoxShape this[int index] { get; }
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | Item's index to get. |
Property Value
Type | Description |
---|---|
ITextBoxShape | Single item from the collection. |
Examples
The following code illustrates how to access a ITextBoxShape from the ITextBoxes collection.
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
ITextBoxShape textbox1 = worksheet.TextBoxes.AddTextBox(1, 1, 20, 100);
ITextBoxShape textbox2 = worksheet.TextBoxes.AddTextBox(5, 5, 20, 100);
//Set name
worksheet.TextBoxes[0].Name = "TextBox1";
worksheet.TextBoxes[1].Name = "TextBox2";
//Save and dispose
workbook.SaveAs("Shapes.xlsx");
workbook.Close();
}
Item[String]
Gets single ITextBoxShape from the ITextBoxes collection.
Declaration
ITextBoxShape this[string name] { get; }
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of the item to get. |
Property Value
Type | Description |
---|---|
ITextBoxShape | Single item from the collection. |
Examples
The following code illustrates how to access a ITextBoxShape from the ITextBoxes collection.
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
ITextBoxShape textbox1 = worksheet.TextBoxes.AddTextBox(1, 1, 20, 100);
ITextBoxShape textbox2 = worksheet.TextBoxes.AddTextBox(5, 5, 20, 100);
//Set name
worksheet.TextBoxes[0].Name = "TextBox1";
worksheet.TextBoxes[1].Name = "TextBox2";
//Get count
Console.Write(worksheet.TextBoxes["TextBox1"].Width);
//Save and dispose
workbook.SaveAs("Shapes.xlsx");
workbook.Close();
Console.ReadKey();
}
//Output will be
//100
Methods
AddTextBox(Int32, Int32, Int32, Int32)
Adds new ITextBoxShape to the ITextBoxes collection. Coordinate means a) in the case of worksheet - row, column - are corresponding row, column indexes of the top-left corner, width and height are measured in pixels b) in the case of chart in Excel 97 all coordinates are measured in 1/4000 of the chart width/height c) in the case of chart in Excel 2007 all coordinates are measured in 1/1000 of the chart width/height
Declaration
ITextBoxShape AddTextBox(int row, int column, int height, int width)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | row | One-based row index of the top-left corner of the new item. |
System.Int32 | column | One-based column index of the top-left corner of the new item. |
System.Int32 | height | Height of the new item. |
System.Int32 | width | Width of the new item. |
Returns
Type | Description |
---|---|
ITextBoxShape | Newly added item. |
Examples
The following code illustrates how to add a ITextBoxShape to the ITextBoxes collection.
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
ITextBoxShape textbox1 = worksheet.TextBoxes.AddTextBox(1, 1, 20, 100);
ITextBoxShape textbox2 = worksheet.TextBoxes.AddTextBox(5, 5, 20, 100);
//Set name
textbox1.Name = "TextBox1";
textbox2.Name = "TextBox2";
//Save and dispose
workbook.SaveAs("Shapes.xlsx");
workbook.Close();
}