We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Problem with integer value 0 executing mail merge

Hi,

we are using mail merge for multiple word document templates and everything working fine, We have but one issue with how Aspose is treating an integer value of 0.

Let us use e.g. the fieldname “totalvat” as a merge field with currency formatting as follows:

{ MERGEFIELD totalvat \# "#.##0,00 €" }

You would expect merging an integer value of 0 the result “0,00€”. This is working as expected with the MailMerge method executeWithRegions(DataSet). BUT with the MailMerge method execute(DataTable) the result is an empty string.

I have tried to convert an integer 0 to string “0” before executing the MailMerge, but with the same result.

I am using JavaBridge with PHP and creating in the same manner for both methods executeWithRegions and execute DataTables. Only difference is for the regions, where I use at the end:

$DataSet->getTables()->add($DataTable);

So maybe I am missing a configuration option or the logic behind both named methods is treating an integer 0 in a different manner…

Do you have any advice?

Thanks

@mrgaijin,

Thanks for your inquiry. Please ZIP and attach your input Word document here for testing. We will investigate the issue on our side and provide you more information.

Sorry for my late response, I didn’t see a notification with an update of my enquiry.

Here is the document, I had to remove some data and normal text formatting cause the information is confidential, but I didn’t touch the merge fields:

kostennote_rsv_gerichtlich_.zip (62.5 KB)

@mrgaijin,

Thanks for sharing the document. We have not found the shared mail merge field in your document. However, we have created a document with following mail merge field, tested the scenario using latest version of Aspose.Words for Java 17.10, and have not found the shared issue. Please use latest version of Aspose.Words for Java 17.10.

{ MERGEFIELD totalvat # “#.##0,00 €” }

If you still face problem, please attach the following resources here for testing:

  • Your input Word document.
  • Please attach the output Word file that shows the undesired behavior.
  • Please create a simple Java application (source code without compilation errors) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we’ll start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip and upload them.

Thanks for your reply, as I was creating the simple Java application for you I stepped into my own code error. So the fault was on my side. The zeros were getting blocked at some point in the code. Thanks anyway for your time. You can close the ticket.