Interface IOptionButtons
This interface represents OptionButton collection inside single worksheet.
Namespace: Syncfusion.XlsIO
Assembly: Syncfusion.XlsIO.UWP.dll
Syntax
public interface IOptionButtons
Properties
Count
Returns number of IOptionButtonShape in the IOptionButtons 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 option button
worksheet.OptionButtons.AddOptionButton(1, 1, 20, 100);
worksheet.OptionButtons.AddOptionButton(5, 5, 20, 100);
//Get count
Console.Write(worksheet.OptionButtons.Count);
//Save and dispose
workbook.SaveAs("Shapes.xlsx");
workbook.Close();
Console.ReadKey();
}
//Output will be
//2
Item[Int32]
Returns single IOptionButtonShape from the IOptionButtons collection.
Declaration
IOptionButtonShape this[int index] { get; }
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | Item's index to get. |
Property Value
Type | Description |
---|---|
IOptionButtonShape | Single item from the collection. |
Examples
The following code illustrates how to access a IOptionButtonShape from the IOptionButtons 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 option button
worksheet.OptionButtons.AddOptionButton(1, 1, 20, 100);
//Set text
worksheet.OptionButtons[0].Text = "Option";
//Save and dispose
workbook.SaveAs("Shapes.xlsx");
workbook.Close();
}
Item[String]
Gets single IOptionButtonShape from the IOptionButtons collection.
Declaration
IOptionButtonShape this[string name] { get; }
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of the item to get. |
Property Value
Type | Description |
---|---|
IOptionButtonShape | Single item from the collection. |
Examples
The following code illustrates how to access a IOptionButtonShape from the IOptionButtons 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 option button
worksheet.OptionButtons.AddOptionButton(1, 1, 20, 100);
//Set text
worksheet.OptionButtons[0].Name = "OptionButton1";
//Get width
Console.Write(worksheet.OptionButtons["OptionButton1"].Width);
//Save and dispose
workbook.SaveAs("Shapes.xlsx");
workbook.Close();
Console.ReadKey();
}
//Output will be
//100
Methods
AddOptionButton()
Adds a IOptionButtonShape width default dimension
Declaration
IOptionButtonShape AddOptionButton()
Returns
Type | Description |
---|---|
IOptionButtonShape | OptionButton Shape |
Examples
The following code illustrates how to add a IOptionButtonShape to the IOptionButtons 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 option button
IOptionButtonShape optionButton = worksheet.OptionButtons.AddOptionButton();
//Set dimensions
optionButton.Top = 1;
optionButton.Left = 1;
optionButton.Width = 100;
optionButton.Height = 20;
//Set text
optionButton.Text = "Option";
//Save and dispose
workbook.SaveAs("Shapes.xlsx");
workbook.Close();
}
AddOptionButton(Int32, Int32)
Adds a IOptionButtonShape with default size.
Declaration
IOptionButtonShape AddOptionButton(int row, int column)
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. |
Returns
Type | Description |
---|---|
IOptionButtonShape | Returns options button. |
Examples
The following code illustrates how to add a IOptionButtonShape to the IOptionButtons 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 option button
IOptionButtonShape optionButton = worksheet.OptionButtons.AddOptionButton(1, 1);
//Set dimensions
optionButton.Width = 100;
optionButton.Height = 20;
//Set text
optionButton.Text = "Option";
//Save and dispose
workbook.SaveAs("Shapes.xlsx");
workbook.Close();
}
AddOptionButton(Int32, Int32, Int32, Int32)
Adds new IOptionButtonShape to the IOptionButtons collection.
Declaration
IOptionButtonShape AddOptionButton(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 in pixels of the new item. |
System.Int32 | width | Width in pixels of the new item. |
Returns
Type | Description |
---|---|
IOptionButtonShape | Newly added item. |
Examples
The following code illustrates how to add a IOptionButtonShape to the IOptionButtons 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 option button
IOptionButtonShape optionButton = worksheet.OptionButtons.AddOptionButton(1, 1, 20, 100);
//Set text
optionButton.Text = "Option";
//Save and dispose
workbook.SaveAs("Shapes.xlsx");
workbook.Close();
}