Delete row with 0 value after merge field

Hi,

I would like to know if there’s a way to delete rows with 0 value after merging. I’m using general merge fields in my table, not merge region. Perhaps I just need to check the second column which is the ‘Count’ column. So, if any record in this column is 0, I would like to delete the whole row.

Thanks,
Raymon

Hi Laurentius,


Thanks for your inquiry. I think, you can achieve what you need by using the following code snippet:
class HandleMergeImageFieldFromBlob implements IFieldMergingCallback {
public void fieldMerging(FieldMergingArgs args) throws Exception {
if (args.getFieldName() == “myCountField” && args.getFieldValue().equals(0)) {
//Create document builder
DocumentBuilder builder = new DocumentBuilder(args.getDocument());
//Move cursor to field
builder.moveToField(args.getField(), true);
//If mergefield is placed in Table we should remove entire row
Row row = (Row) builder.getCurrentParagraph().getAncestor(NodeType.ROW);
if (row != null)
row.remove();
}
}

<font color="RED"><b>public</b></font> <font color="RED"><b>void</b></font> imageFieldMerging<font color="BLUE"><b>(</b></font>ImageFieldMergingArgs e<font color="BLUE"><b>)</b></font> <font color="RED"><b>throws</b></font> Exception <font color="BLUE"><b>{</b></font>
    <font color="GREEN"><i>/* DO NOTHING */</i></font>
<font color="BLUE"><b>}</b></font>

}

For more information about IFieldMergingCallback, please visit the following link:
http://docs.aspose.com/display/wordsjava/IFieldMergingCallback

I hope, this will help.

Best Regards,

Hi Awais,

Is there any simpler code snippet to make it work? I’m using coldfusion to develop the program, so it’s kinda complicated for me to convert your code to coldfusion. I’m thinking about using bookmark to go to the table which I want to check. Something like this:


—>


Thanks,
Raymon

Hi
Laurentius,


Thanks for your inquiry and sorry for the delayed response. I am not a ColdFusion expert. I would simply suggest you please first create your code in Java, compile it into a Jar and then use this Jar in your ColdFusion application. As a sample, I would suggest you please see below the Mail Merge with Regions example:
http://docs.aspose.com/display/wordsjava/ColdFusion+++Aspose.Words+for+Java

I hope, this will help.

Best Regards,