Skip to main content linkedinfacebooktwittermenuarrow-up
6

API support for form controls (like dropdown) Completed

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

Official response

Mario at GemBox

Hi,

This feature request has been implemented and is available in the latest versions of GemBox.Spreadsheet.

Regards,
Mario

Comments (5)

Mario at GemBox
Hi, GemBox.Spreadsheet currently lacks API support for these elements, for now, they are supports only through preservation. Note, this is a feature that we hope to provide some time 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: https://www.gemboxsoftware.com/spreadsheet/examples/excel-forms-macros/802 The input file, "FormsAndMacros.xlsm", has controls that have "Cell link:" specified to some cell. You may notice that the DropDown control has an "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. Regards, Mario
TrungThongHoang
Can I get text value of dropdown instead of get index? How to do it?
TrungThongHoang
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 at GemBox
Hi, Because of the lack of API support, the value cannot be retrieved from that dropdown (combo box) control, only the 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(); Console.WriteLine(selectedValue); } You can find the input file attached to this feature request. I hope this helps. Regards, Mario
TrungThongHoang
Thank you so much

Attachments