简体   繁体   English

如何使用Jxl API读取下拉列表的值

[英]How to read the values of a dropdown using Jxl API

I have an Excel sheet in which 2 columns have a dropdown with one about 4-5 values and the other with 2 values that can be selected. 我有一个Excel工作表,其中2列有一个下拉列表,其中一个带有约4-5个值,另一个带有2个可以选择的值。 I would like to read the value that is there for each row in these two columns. 我想读取这两列中每一行的值。 . What is the code sample to do that? 这样做的代码示例是什么? I did browse a while on the net and this forum, but did not find any answers. 我确实在网上和这个论坛上浏览了一段时间,但没有找到任何答案。 I posted in the JExcel Yahoo groups , but no success. 我在JExcel Yahoo组中发布,但没有成功。 I have added the following code, but this does not help. 我添加了以下代码,但这无济于事。 This code sample just prevents the "common Assertion failed" error 此代码示例只是防止“公共声明失败”错误

 WorkbookSettings settings = new WorkbookSettings();
  settings.setSuppressWarnings(true);
 Workbook workbook = Workbook.getWorkbook(sis, settings);

The sheet gives an erroneous row count when the dropdown is there. 当下拉列表在那里时,工作表给出了错误的行数。 Has anyone been able to read the values selected in the drop down ? 是否有人能够读取下拉菜单中选择的值?

If you have applied an autofilter to your Excel sheet then probably that is responsible for the issue. 如果您已将自动筛选器应用于Excel工作表,则可能是造成此问题的原因。 I would suggest you to please remove the autofilter and then try fetching the value of the combobox. 我建议您删除自动筛选器,然后尝试获取组合框的值。

Cell yourCell = yourSheet.getCell(x,y);
String comboboxValue = yourCell.getContents();
logger.log("value selected in combobx is : " + comboboxValue );

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM