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.

Thu Jun 11, 2020 6:25 pm

I want to be able to hide both the label text and the MergeField if the value of the MergeField is "$0.00"

RefundingMoney is a Merge field.

This is what I have in an IF field
IF { RefundingMoneyProposed } = "$0.00" "" "Refunding Money:"

This does not work.
Last edited by terrence@mactexas.com on Fri Jun 12, 2020 4:02 pm, edited 2 times in total.

terrence@mactexas.com
 
Posts: 95
Joined: Tue May 19, 2015 8:09 pm

Fri Jun 12, 2020 2:35 am

Hello,

Thanks for your inquiry.
Please refer to the code below and attached are my template file and output file. If there are any questions, please feel free to write back.
Code: Select all
    Document document = new Document();
    document.LoadFromFile("IFField.docx");
    //Mailmerge
    string[] fieldNames = new string[] { "RefundingMoneyProposed"};
    string[] fieldValues = new string[] { "$0.00" };
    document.MailMerge.Execute(fieldNames, fieldValues);
    //Update fields
    document.IsUpdateFields = true;
    document.SaveToFile("Result.docx", FileFormat.Docx);


Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Fri Jun 12, 2020 1:25 pm

Thank you Rachel.

The IFField.docx only has text in it.
I need to see the actual IF field.
Could you post the doc again please.

terrence@mactexas.com
 
Posts: 95
Joined: Tue May 19, 2015 8:09 pm

Fri Jun 12, 2020 4:03 pm

What is the syntax for an IF field?
These does not work. They always returns "No" even though the HasRefunding field is set to "True"

IF { HasRefunding} = "True" "yes" "No:"
IF { HasRefunding = "True"} "yes" "No:"

IF {MERGEFIELD HasRefunding} = "True" "Yes" "No"
IF {MERGEFIELD HasRefunding = "True"} "Yes" "No"

IF <<HasRefunding>> = "True" "yes" "No:"

terrence@mactexas.com
 
Posts: 95
Joined: Tue May 19, 2015 8:09 pm

Mon Jun 15, 2020 1:51 am

Hello,

Sorry for the late reply as the weekend.
For the template file "IFField.docx" I provided, the field code is shown below, you can press Alt+F9 to view it.
IF_Field.png


And the syntax for the IF field nested Merge filed is as follows. If there is any question, please provide your template file as well as your desired output for further investigation.
Code: Select all
{IF { MERGEFIELD  HasRefunding  \* MERGEFORMAT } = "True" "yes" "No:" \* MERGEFORMAT }


Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Mon Jun 15, 2020 2:27 pm

Thank you.

terrence@mactexas.com
 
Posts: 95
Joined: Tue May 19, 2015 8:09 pm

Tue Jun 16, 2020 1:10 am

Hello,

You are welcome.
If you encounter any issue related to our product in the future, please feel free to contact us.
Have a nice day!

Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Return to Spire.Doc