I am currently evaluating the Spire.Doc Java library to determine if it is suitable for my particular use case. The problem I am experiencing is with regards to mail merge conditional fields, I can't seem to get even the most basic of mail merge conditional fields to work. You can see the conditional field I am trying to evaluate below.
conditional field:
{ IF "{ MERGEFIELD Account.PaymentMethodType \* MERGEFORMAT }" <> "CreditCard" "Direct Debit" "Not Direct Debit" }
The above merge field evaluates to:
{ IF "Bank" <> "CreditCard" "Direct Debit" "Not Direct Debit" }
As can you see the simple field ({ MERGEFIELD Account.PaymentMethodType \* MERGEFORMAT }) evaluates fine but the conditional statement is not processed. I have included the code I am using as well as the template document for your convenience. Can you please assist me in this matter?
Version:
5.1.9
Template:
Code:
- Code: Select all
// open template
Document document = new Document();
document.loadFromFile("path-to-file", FileFormat.Docx);
// mock data
String[] fieldNames = new String[]{"Account.AccountNumber", "Account.PaymentMethodType", "BillToContact.Address"};
String[] fieldValues = new String[]{"C00000001", "Bank", "Address"};
// execute mail merge
document.getMailMerge().execute(fieldNames, fieldValues);
// save invoice
document.saveToFile("path-to-save-file", FileFormat.Docx);