poi3.5里没有了HSSFDataValidation,如何生成下拉菜单

来源:百度知道 编辑:UC知道 时间:2024/06/25 08:17:01
请问 poi3.5里没有了HSSFDataValidation,如何生成下拉菜单,有没有什么替代类?谢谢!!

Right at the start I should say that I have never done this myself and that I got this piece of code from a discussion that was led by Pierre Lavignotte and contributed to by a few other users so can claim no credit at all if it works.

Having said all of that, I think that you need to look at the HSSFDataValidation class. As far as I can see, it uses a named range of cells to provide the basis for the validation of the input a user makes. Further, it seems that it is possible to make this validation work in a few different ways, one of whihc is to use a drop down list.

I have not tried or tested this code myself - it was always something I intended to do when I got the time - so can make no promises for it. Nevertheless, here is the code that the group worked on;

HSSFSheet sheet = wb.getSheet("Sheet1");
HSSFName namedRange = wb.createName();
namedRange.setNameName("NAMEDAREA");
namedRange.setReference("Sheet1!$