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.

Wed Mar 19, 2014 1:56 pm

Hi!

I'm evaluating Spire.Doc for our needs. Our software is used in most of the Scandianvia countries (mainly Denmark, but also Sweeden, Norway, and Finland) and we have a need for localization. Hence, I'm doing a test for MailMerge using a Word template formulated in a Danish Word, and some dummy data from a dataset.

In Danish the number "one hundred" with to decimals is written: 100,00. In USA, the same number is written: 100.00.
Word gives the abillity to format data comming from a MergeField. Fx. dates can be formatted to you hearts content. I'm glad to see that the formatting acutally is executed when performing MailMerge via Spire.Doc.

So what's the deal, then? Well, I'm having problems formatting decimal numbers.
In my Danish Word template I have:
Decimal(,): {MERGEFIELD "Decimal" \# "0,00"}
Decimal(.): {MERGEFIELD "Decimal" \# "0.00"}

This results to the following in after doing a MailMerge in Danish Word :
Decimal(,): 123,87
Decimal(.): 124
which is expected as, dot marks a thousand-separator in Danish.

Using your Spire.Doc I get this result:
Decimal(,): 123.87
Decimal(.): 12400"
which is wrong in more than one aspect.
1) Spire.Doc did recognize the decimal separator in the first row, but fails to show it correctly. It uses dot in stead of comma.
2) using the dot as thousand separator is expectedly giving weird results, but why the "? I have made a precise representation of the formulas entered above.

How do I make Spire.Doc show the comma in stead of the dot? I'm not able to format (ToString()) the data myself?
/Thomas

thb@sonlinc.dk
 
Posts: 4
Joined: Thu Feb 20, 2014 11:43 am

Thu Mar 20, 2014 7:55 am

Hello,

Thanks for evaluating our product and inqury.
Our Dev team has fixed the issue, and now our test team is testing the hotfix. Once it works fine, we will release the hotfix and let you know ASAP.
If there are any questions, welcome to get it back to us.
Sincerely,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Thu Mar 20, 2014 8:40 am

Thank you for a quick response!

How will you fix this? Will there be an option to override the machine dependent CultureInfo (.NET lingo) by a custom CultureInfo?

/Thomas

thb@sonlinc.dk
 
Posts: 4
Joined: Thu Feb 20, 2014 11:43 am

Thu Mar 20, 2014 9:08 am

Before we couldn't write the comma in the field into the document, it will be replaced by dot, now we change some codes to make the comma not be replaced. And we also need to change the data format by setting cultureInfo in MergeField event because of the invariant culture.
Anyway, once it is released, we will provide you the corresponding method.
If there are any questions, welcome to get it back to us.
Sincerely,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Thu Mar 27, 2014 8:02 am

Sorry for long silence.
The newest hotfix of Spire.Doc has been released, you could download Spire.Doc Pack(hot fix) Version:5.0.30 and test the below code.
Code: Select all
static void MailMerge_MergeField(object sender, MergeFieldEventArgs args)
        {
            MergeField mergefield = args.CurrentMergeField as MergeField;
            System.Globalization.CultureInfo culture = new System.Globalization.CultureInfo("da-DK");
            double d = Convert.ToDouble(args.Text);
            string s = d.ToString(mergefield.NumberFormat, culture);
            args.Text = s;
        }

If there are any questions, welcome to get it back to us.
Sincerely,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Thu Mar 27, 2014 9:28 am

Thank you!
I did not find the waiting long.

I have a question. What CultureInfo is used by default? Will the formatting be executed by default or do I have to implement the method as shown?

Regards,
Thomas

thb@sonlinc.dk
 
Posts: 4
Joined: Thu Feb 20, 2014 11:43 am

Fri Mar 28, 2014 2:25 am

Hello,

Thanks for the reply.

Sorry that the formatting is not executed by default as the default culture is invariant in our library, so you have to set the culture you need.

If there are any questions, welcome to get it back to us.

Sincerely,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Return to Spire.Doc