I am reading a docx template which has a table and generating docx document after populating the data. Can you throw some light on following items: a) I want to add checkbox in one of the columns of a table. I am generating a table. b) I have a checkbox which has a bookmark, i want to update its value. For e.g. bookmark value="MybkCheckbox" update checkbox value as checked.
Using following code i get the bookmark class object but how do i replace bookmark value
...
List<Object> bk= getAllElementFromObject(template.getMainDocumentPart(), CTBookmark.class);
...
private static List<Object> getAllElementFromObject(Object obj, Class<?> toSearch) {
List<Object> result = new ArrayList<Object>();
if (obj instanceof JAXBElement) obj = ((JAXBElement<?>) obj).getValue();
if (obj.getClass().equals(toSearch))
result.add(obj);
else if (obj instanceof ContentAccessor) {
List<?> children = ((ContentAccessor) obj).getContent();
for (Object child : children) {
result.addAll(getAllElementFromObject(child, toSearch));
}
}
return result;
}
Aucun commentaire:
Enregistrer un commentaire