@mp2,
You can use the following Java code of Aspose.Words for Java API to get the desired result
Document doc = new Document(srcFile);
Table table = (Table)doc.getChild(NodeType.TABLE, 0, true);
RowCollection rows = table.getRows();
for (int i = 0; i < rows.getCount(); i++)
{
NodeCollection<StructuredDocumentTag> nc = rows.get(i).getChildNodes(NodeType.STRUCTURED_DOCUMENT_TAG, true);
for (StructuredDocumentTag sdt : nc) {
if (sdt.getSdtType() == SdtType.CHECKBOX)
if (sdt.getChecked()) {
rows.get(i+1).remove(); //in the sample document, the "response" cells are considered to be the new row, so we need to remove them too
rows.get(i).remove();
i--;
}
}
}
//removing the blank sections
for (int i = 0; i < rows.getCount()-1; i++)
{
boolean blankSection = false;
if ((rows.get(i).getFirstCell().getText().length() >= 7) && (rows.get(i).getFirstCell().getText().substring(0, 7).equals("Section")) &&
(rows.get(i+1).getFirstCell().getText().length() >= 7) && (rows.get(i+1).getFirstCell().getText().substring(0, 7).equals("Section"))) {
rows.get(i).remove();
i--;
}
}
//if the last row is "other" row, then delete it
Row lastRow = rows.get(rows.getCount()-1);
if (lastRow.getFirstCell().getText().substring(0, 5).equals("Other"))
lastRow.remove();
doc.save(destFile);