alexa
menu

MAUI

  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Search Results for

    Show / Hide Table of Contents

    Interface IOptionButtons

    This interface represents OptionButton collection inside single worksheet.

    Namespace: Syncfusion.XlsIO
    Assembly: Syncfusion.XlsIO.NET.dll
    Syntax
    public interface IOptionButtons

    Properties

    Count

    Returns number of IOptionButtonShape in the IOptionButtons collection.

    Declaration
    int Count { get; }
    Property Value
    Type
    int
    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

    this[int]

    Returns single IOptionButtonShape from the IOptionButtons collection.

    Declaration
    IOptionButtonShape this[int index] { get; }
    Parameters
    Type Name Description
    int 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();
    }

    this[string]

    Gets single IOptionButtonShape from the IOptionButtons collection.

    Declaration
    IOptionButtonShape this[string name] { get; }
    Parameters
    Type Name Description
    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(int, int)

    Adds a IOptionButtonShape with default size.

    Declaration
    IOptionButtonShape AddOptionButton(int row, int column)
    Parameters
    Type Name Description
    int row

    One-based row index of the top-left corner of the new item.

    int 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(int, int, int, int)

    Adds new IOptionButtonShape to the IOptionButtons collection.

    Declaration
    IOptionButtonShape AddOptionButton(int row, int column, int height, int width)
    Parameters
    Type Name Description
    int row

    One-based row index of the top-left corner of the new item.

    int column

    One-based column index of the top-left corner of the new item.

    int height

    Height in pixels of the new item.

    int 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();
    }
    In this article
    Back to top Generated by DocFX
    Copyright © 2001 - 2026 Syncfusion Inc. All Rights Reserved