0

Can you please suggest me how to create dropdown list using POI 3.6 in excel sheet column?

Thanks in Advance.

Somnath Guha
  • 107
  • 3
  • 13
  • Why are you using POI 3.6 instead of 3.8? 3.6 is over two years old, and there have been [lots and lots of bug fixes](http://poi.apache.org/changes.html) since then! – Gagravarr Jun 05 '12 at 15:22
  • Actually 3.6 has been already used in several other parts of the project. That is why I do not want to upgrade the version in sort span of time – Somnath Guha Jun 05 '12 at 15:44
  • http://stackoverflow.com/questions/10534095/excel-drop-down-list-using-apache-poi – Siddharth Rout Jun 05 '12 at 17:20
  • http://stackoverflow.com/questions/8655185/limitation-while-generating-excel-drop-down-list-with-apache-poi – Siddharth Rout Jun 05 '12 at 17:21

1 Answers1

2

Try this,

{
   CellRangeAddressList addressList = 
   new CellRangeAddressList(1,10,columnIndexFromHeaderList,columnIndexFromHeaderList);
   DVConstraint dvConstraint = 
   DVConstraint.createExplicitListConstraint(stringArray);
   dataValidation = new HSSFDataValidation(addressList,dvConstraint);                      
   dataValidation.setSuppressDropDownArrow(false);
   sheet.addValidationData(dataValidation );
}
Komal12
  • 3,340
  • 4
  • 16
  • 25
user2507974
  • 122
  • 1
  • 2
  • 15
  • 1
    Thanks a lot. Is there any way to limit the user to select only the values from the dropdown. Because the above code will let the user enter his own value apart from the drop down values. – Jeffin Manuel Nov 22 '16 at 06:47