I'm currently writing program which reads values from an excel file. For normal cells it works just fine, but there are also textboxes, selectboxes and comboboxes, which i can't really access. I know, that these elements were created with an id.
Here is my current try:
private void processExcelToXml(File excelFile) throws EncryptedDocumentException, IOException {
HSSFWorkbook workbook = new HSSFWorkbook(new FileInputStream(excelFile));
List<HSSFObjectData> embeddedObjects = workbook.getAllEmbeddedObjects();
List<HSSFObjectData> textBoxList = new ArrayList<>();
List<HSSFObjectData> comboBoxList = new ArrayList<>();
List<HSSFObjectData> checkBoxList = new ArrayList<>();
for (HSSFObjectData hssfObjectData : embeddedObjects) {
log.info(hssfObjectData.getDirectory().getName());
switch (hssfObjectData.getOLE2ClassName()) {
case "Forms.TextBox.1":
textBoxList.add(hssfObjectData);
break;
case "Forms.CheckBox.1":
checkBoxList.add(hssfObjectData);
break;
case "Forms.ComboBox.1":
comboBoxList.add(hssfObjectData);
break;
default:
break;
}
}
}
I know there is an solutuion(Obtain textbox value from Excel in Java), but like the the OP I don't get any instances of HSSFTextbox, but only of HSSFObjectData. My Question is, can I extract the value typed into the textbox from these HSSFObjectDatas?
Thanks!