Hello,
Our client reported the following behavior related to mail merge:
Zero values are not supported when using the hash symbol (#) in both decimal and integer formats (e.g., 250.00 is displayed as 250.). This issue can be resolved by replacing the hash symbol in the switch with a zero (e.g., changing \# "#.#"
to \# "#.0"
). If the value is 0 the result after merge is blank.
We reproduces with the following switches:
- \# "#,0.00"
for US formatting.
- \# "#.0,00"
for Dutch (Netherlands) formatting.
Regards
@profiler
It seems that you are encountering an issue with zero values being displayed as blank when using specific formatting switches in your mail merge operations. This behavior occurs because the hash symbol (#) in the formatting string does not account for zero values, leading to them being omitted from the output.
To resolve this issue, you can modify your formatting switches by replacing the hash symbol with a zero. For example, instead of using \# "#.#"
or \# "#,0.00"
for US formatting, you should change it to \# "#.0"
or \# "0.00"
respectively. This adjustment ensures that when the value is zero, it will display as “0” instead of being blank.
Here’s a summary of the changes you can make:
- Change
\# "#,0.00"
to \# "0.00"
for US formatting.
- Change
\# "#.0,00"
to \# "0,00"
for Dutch (Netherlands) formatting.
By implementing these changes, you should be able to display zero values correctly in your merged documents.
If you need further assistance or have additional questions, feel free to ask!
Sources:
[1]: Mail Merge and Reporting - Aspose Documentation
[2]: LINQ Reporting Engine or Mail Merge - Aspose Documentation
The issue is not observed in our previous version when we used Spire for merge. Also is not reproduced in Word Mail Merge.
@profiler Here is what MS Word says about 0
and #
number format symbols:
- 0 (zero) This format item specifies the requisite numeric places to display in the result. If the result does not include a digit in that place, Word displays a 0 (zero). For example,
{ = 4 + 5 \# 00.00 }
displays 09.00.
- # This format item specifies the requisite numeric places to display in the result. If the result does not include a digit in that place, Word displays a space. For example,
{ = 9 + 6 \# $### }
displays $ 15.
So it is expected that space is displayed when zero value is formatted with #
. In your case MS Word formats the following code { = 1-1 \# "#,0.00" }
as 0.00
, Aspose.Words does the same.
If possible, could you please create a simple template, provide code, output and expected output documents here for our reference? We will check the issue once again on our side.
Thanks for the quick reply!
Here test data.zip you can find more information about the issue and a sample template.
@profiler The behavior is expected You can check with the following fields in MS Word:
{ = 0 \# "#,##0.00" }
{ =0 \# "#,##0" }
{ =0 \# "0" }
output is the following:
0.00
0
0
So you can get either 0.0
value (with one decimal zero) using 0.#
format, or 0
using 0
or #,##0
format.
The client is fine with this, thanks!
1 Like