I have two dropdown list in word, both has an item with display name = “choose an item” and value = ‘’, as in attachment image,
but in code
ByteArrayOutputStream baOutputStream = new ByteArrayOutputStream();
InputStream in;
in = this.getClass().getResourceAsStream("/resources/dropdown1.docx");
Document doc = new Document(in);
NodeCollection sdtNodes = doc.getChildNodes(NodeType.STRUCTURED_DOCUMENT_TAG, true);
for (StructuredDocumentTag sdt : (Iterable<StructuredDocumentTag>)sdtNodes)
if (sdt.getSdtType() == SdtType.DROP_DOWN_LIST)
for (SdtListItem item : (Iterable<SdtListItem>)sdt.getListItems()) {
System.out.println(item.getDisplayText() + " | " + item.getValue());
}
doc.save(baOutputStream, SaveFormat.DOCX);
- only one dropdown list (dropdown1) has item.value = “| Choose an item.” (but not in item.getDisplayText()), another dropdown list (civilDept5_1) even has no item with value or displayText = “Choose an item”, why?
- when I save the document and download the document, I find only one dropdown list (dropdown1) has the “choose an item” choice, another dropdown list (civilDept5) has lost this choice, why?
dropdown_1.jpg (118.9 KB)
civitDept5_1.jpg (154.9 KB)
code1.jpg (138.3 KB)