Hello Aspose team,
I am using aspose java library for word to process the word document.
I have a word document that contains tables and within the table there are checkboxes in some cells. I have attached the sample document. The logic used to read data from the document is not able to recognize check-boxes within the table, so I am not able to get info whether the check-boxes in the table are checked or not checked. I also need to know a particular checbox is in which cell. The code used is as below:
InputStream fis = new FileInputStream(fileName);
Document doc = new Document(fis);
NodeCollection nodes = doc.getChildNodes(NodeType.TABLE, true);
for (Iterator<Node> itr = nodes.iterator(); itr.hasNext(); ++count) {
nod = itr.next()
Table table = (Table) nod;
RowCollection rowColl = table.getRows();
for (int i = 0; i < rowColl.getCount(); ++i) {
com.aspose.words.Row rowdata = rowColl.get(i);
CellCollection cells = rowdata.getCells();
int columnCount = cells.getCount();
for (int colIndex = 0; colIndex < columnCount; colIndex++) {
com.aspose.words.Cell cell = rowdata.getCells().get(colIndex);
if (cell != null) {
cellJson.put("cellData", cell.getText());
cellJson.put("columnIndex", colIndex);
if ( cell.getChildNodes() != null) {
NodeCollection cellNodes = cell.getChildNodes();
for ( int nodeIndex =0; nodeIndex < cellNodes.getCount(); nodeIndex ++) {
logger.info("cell child node type:" + cellNodes.get(nodeIndex).getNodeType());
if (cellNodes.get(nodeIndex).getNodeType() == FieldType.FIELD_FORM_CHECK_BOX ) {
FormField field1= (FormField)cellNodes.get(nodeIndex);
logger.info("ccell has checkbox. is it checked:" + field1.getChecked());
cellJson.put("checked", field1.getChecked());
}
}
}
}
}
}
}