Skip to main content facebooktwittermenuarrow-up

API support for form controls (like dropdown) - Community / GemBox.Spreadsheet Feature Request - GemBox Support Center

Hi supporter, i want to get value of any dropdown or any control in xlsm file when convert from xlsm file to xlsx or pdf file. Please help me how to get it. Thanks

Comments (5)

Mario - GemBox

GemBox.Spreadsheet currently lacks an API support for these elements, for now they are supports only through a preservation.

Note, this is a feature which we hope to provide sometime in the future, but at the moment there are other requests with greater priority.

Nevertheless, note that you could read and write the form field values indirectly, by using linked cells.

For instance, take a look at the following example:

The input file, "FormsAndMacros.xlsm", has controls which have "Cell link:" specified to some cell.
You may notice that the DropDown control has "F8" linked cell, changing the value of that linked cell will trigger the change in the control, and changing the value in the control will trigger the change in that linked cell.


GemBox d.o.o.
Can I get text value of dropdown instead of get index? How to do it?
Example, When I click to change dropdown in "D8", it link value to "F8" but value is 1 or 2 but I want to get value is "USA" or "Japan". Can I get it? And please tell me how to get it by method or any code.
Mario - GemBox

Because of the lack of an API support the value cannot be retrieved from that dropdown (combo box) control, only index can be retrieved.

But, if you use named range then you could retrieve it like the following:

ExcelFile workbook = ExcelFile.Load("DropDownWithNamedRange.xlsx");
ExcelWorksheet worksheet = workbook.Worksheets[0];

CellRange dropDownRange = worksheet.NamedRanges["MyDropDownRange"].Range;

ExcelCell linkedCell = worksheet.Cells["J4"];
int dropDownIndex = linkedCell.ValueType != CellValueType.Int ? -1 : linkedCell.IntValue - 1;

if (dropDownIndex != -1)
string selectedValue = dropDownRange[dropDownIndex].Value.ToString();

You can find the input file attached to this feature request.
I hope this helps.


GemBox d.o.o.
Thank you so much

Add a comment

Please log in or register to submit a comment.

Need a password reminder?