Reputation: 159
I am stuck here and tried everything to read dropdown list from .xlsx file. Please share some code which illustrate the things how Apache POI can be used
Upvotes: 1
Views: 1839
Reputation: 21809
As a starting point you can try to work with getDataValidations
of XSSFSheet
.
XSSFWorkbook wb = null;
try {
wb = (XSSFWorkbook) WorkbookFactory.create(new FileInputStream("D:\\testWB.xlsx"));
} catch (EncryptedDocumentException | InvalidFormatException | IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
XSSFSheet sheet = wb.getSheetAt(0);
List<XSSFDataValidation> dataValidations = sheet.getDataValidations();
Iterator<XSSFDataValidation> iterator = dataValidations.iterator();
while(iterator.hasNext()){
XSSFDataValidation dataValidation = iterator.next();
String[] explicitListValues = dataValidation.getValidationConstraint().getExplicitListValues();
}
Upvotes: 1
Reputation: 11
You have to use jExcel API. It uses Apache POI and is really easy to handle:
net.sourceforge.jexcelapi:jxl:2.6.12
you can try it.
WorkSheet sheet;
Cell comboBox = sheet.getCell(x,y);
String value= comboBox.getContents();
Upvotes: 0