Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Sun Oct 19, 2025 12:22 pm

Hi

I am using the free version of spire.doc for python to create a mail merge template. I'd like to determine the difference of two fields in an if statement to make a decision:
Code: Select all
{IF {= {MERGEFIELD field1} - {MERGEFIELD field1}} > 20 "Good" "Bad"}


I can't work out how to output the
Code: Select all
 {= {MERGEFIELD field1} - {MERGEFIELD field1}}
part in my code. I need to open a brace, then add two field inside the brace before closing it. Any help would be welcome.

Thank you,
Martyn

martyn_wheeler
 
Posts: 2
Joined: Sun Oct 19, 2025 12:12 pm

Sun Oct 19, 2025 9:45 pm

Hi,

I have solved it. I just used an iffield statement and used an = sign rather than an IF.

All works

martyn_wheeler
 
Posts: 2
Joined: Sun Oct 19, 2025 12:12 pm

Mon Oct 20, 2025 2:15 am

Hello,

Glad to hear your issue has been resolved.
If you have any questions or need further assistance, please don't hesitate to let us know .
Sincerely,
Talia
E-iceblue support team
User avatar

talia.liu
 
Posts: 341
Joined: Mon Apr 14, 2025 3:33 am

Return to Spire.Doc