We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How do I insert a Combobox in a cell using Essential XlsIO

Platform: WinForms |
Control: XlsIO

Syncfusion Essential XlsIO is a .NET Excel library to create, read and edit Excel documents. Using this library, you can add Combo Box into an Excel cell.

Steps to insert a Combo Box into an Excel cell programmatically:

  1. Create a new C# Windows Forms application in Visual Studio.

Create Windows Forms application

Create Windows Forms application

  1. Install the Syncfusion.XlsIO.WinForms NuGet package as reference to your .NET Framework application from NuGet.org.

Add NuGet package to the project

Add NuGet package to the project

  1. Add a new button in Form1.Designer.cs file to create an Excel file with Combo Box.



private Button btnCreate;
private Label label;
private void InitializeComponent()
    this.btnCreate = new System.Windows.Forms.Button();
    this.label = new System.Windows.Forms.Label();
    // addComboBox
    this.btnCreate.Location = new System.Drawing.Point(119, 99);
    this.btnCreate.Name = "btnCreate";
    this.btnCreate.Size = new System.Drawing.Size(186, 26);
    this.btnCreate.TabIndex = 1;
    this.btnCreate.Text = "Add Combo Box";
    this.btnCreate.Click += new System.EventHandler(this.addComboBox_Click);
    // label
    this.label.Location = new System.Drawing.Point(0, 40);
    this.label.Name = "label";
    this.label.Size = new System.Drawing.Size(426, 35);
    this.label.TabIndex = 0;
    this.label.Text = "Click the button to view an Excel spreadsheet generated by Essential XlsIO. Pleas" +
    "e note that MS Excel Viewer or MS Excel is required to view the resultant docume" +
    this.label.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
    // Form1
    this.ClientSize = new System.Drawing.Size(450, 150);
    this.Name = "Form1";
    this.Text = "Create Spreadsheet";



Private label As Label
Private WithEvents btnCreate As Button
Private Sub InitializeComponent()
    label = New Label()
    btnCreate = New Button()
    btnCreate.Location = New Drawing.Point(119, 99)
    btnCreate.Size = New Drawing.Size(186, 26)
    btnCreate.Text = "Add Combo Box"
    AddHandler btnCreate.Click, AddressOf Me.addComboBox_Click
    label.Location = New Drawing.Point(0, 40)
    label.Size = New Drawing.Size(426, 35)
    label.Text = "Click the button to view an Excel spreadsheet generated by Essential XlsIO. Please note that MS Excel Viewer or MS Excel is required to view the resultant document."
    label.TextAlign = Drawing.ContentAlignment.MiddleCenter
    'Create Spreadsheet
    ClientSize = New Drawing.Size(450, 150)
    Text = "Create Spreadsheet"
End Sub


  1. Include the following namespaces in Form1.cs file.



using Syncfusion.XlsIO;



Imports Syncfusion.XlsIO


  1. Include the following complete code snippet in addComboBox_Click, the button click event, in Form1.cs, to create simple Excel document with Combo Box inserted in an Excel cell.



//Initialize ExcelEngine
using (ExcelEngine excelEngine = new ExcelEngine())
    //Initialize IApplication
    IApplication application = excelEngine.Excel;
    //Set the default application version
    application.DefaultVersion = ExcelVersion.Excel2016;
    //Create a new Excel workbook
    IWorkbook workbook = application.Workbooks.Create(1);
    //Access the first worksheet in the workbook
    IWorksheet worksheet = workbook.Worksheets[0];
    //Add data in worksheet
    worksheet["A2"].Text = "RGB colors";
    worksheet["A3"].Text = "Red";
    worksheet["A4"].Text = "Green";
    worksheet["A5"].Text = "Blue";
    worksheet["B5"].Text = "Selected Index";
    //Add a Combo Box in worksheet
    IComboBoxShape comboBox = worksheet.ComboBoxes.AddComboBox(2, 3, 20, 100);
    //Assign value to the Combo Box
    comboBox.ListFillRange = worksheet["A3:A5"];
    comboBox.LinkedCell = worksheet["C5"];
    comboBox.SelectedIndex = 2;
    //Save the Excel workbook and open it for viewing



'Initialize ExcelEngine
Using excelEngine As ExcelEngine = New ExcelEngine
    'Initialize IApplication
    Dim application As IApplication = excelEngine.Excel
    'Set the default application version
    application.DefaultVersion = ExcelVersion.Excel2016
    'Create a new Excel workbook
    Dim workbook As IWorkbook = application.Workbooks.Create(1)
    'Access the first worksheet in the workbook
    Dim worksheet As IWorksheet = workbook.Worksheets(0)
    'Add data in worksheet
    worksheet("A2").Text = "RGB colors"
    worksheet("A3").Text = "Red"
    worksheet("A4").Text = "Green"
    worksheet("A5").Text = "Blue"
    worksheet("B5").Text = "Selected Index"
    'Add a Combo Box in worksheet
    Dim comboBox As IComboBoxShape = worksheet.ComboBoxes.AddComboBox(2, 3, 20, 100)
    'Assign value to the Combo Box
    comboBox.ListFillRange = worksheet("A3:A5")
    comboBox.LinkedCell = worksheet("C5")
    comboBox.SelectedIndex = 2
    'Save the Excel workbook and open it for viewing
End Using


A complete working sample to create an Excel document with Combo Box inserted in an Excel cell can be downloaded from Insert ComboBox in Excel cell.zip.

By executing the program, you will get the Excel file as follows.

Excel file with Combo Box

Excel file with Combo Box

Take a moment to peruse the documentation, where you can find basic worksheet data manipulation options along with features like Conditional Formatting, worksheet calculations through Formulas, adding Charts in worksheet or workbook, organizing and analyzing data through Tables and Pivot Tables, appending multiple records to worksheet using Template Markers, and most importantly PDF and Image conversions with code examples.

Refer here to explore the rich set of Syncfusion Excel (XlsIO) library features.


Starting with v16.2.0.x, if you reference Syncfusion assemblies from trial setup or from the NuGet feed, include a license key in your projects. Refer the link to learn about generating and registering Syncfusion license key in your application to use the components without trial message.



2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile