Changing the value in a drop down list Excel C#

后端 未结 3 1211
南旧
南旧 2021-01-25 19:02

so I have asked how to change the value in a cell inside of excel using c#, but what if I want to change the value of a drop down list. The code I am using for sheet modifying i

3条回答
  •  囚心锁ツ
    2021-01-25 20:02

    Use this to navigate through the drop down list.If you are using drop down object. We are using shapes.item

    You need to identify the shape object name from your excel.

    var control = xlWorksheet.Shapes.Item("Drop Down 22").ControlFormat;
    control.ListIndex = 5; \\This allows you to change the drop down to 5th element
    

    In case you are trying to change a combo box which is based on the cell of a excel sheet , you can directly change the cell value

     Excel.Range xlRangeloc= xlWorksheetH.get_Range("D5");
    
                                xlRangeloc.Value = "OptionOne";
    

提交回复
热议问题