This is a migrated thread and some comments may be shown as answers.

Map Coordinates Export to Excel Localization

5 Answers 39 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jason
Top achievements
Rank 1
Jason asked on 25 Oct 2013, 08:24 PM
I am trying to make an Excel document from a Grid. The Excel export needs to work in multiple international locations. It currently works fine when viewed from a en-US computer, but when viewed from a it-IT computer the format of the latitude and longitude are incorrect. See the example below. I am not explicitly setting the culture either at page load or during the export. I have tried setting an invariant culture, but that doesn't appear to work either.

In grid on the website
en-US Latitude = -33.85563
it-IT Latitude = -33.85563
In exported Excel
en-US Latitude = -33.85563
it-IT Latitude = -3385563,00 (this should be -33,85563)

5 Answers, 1 is accepted

Sort by
0
Kostadin
Telerik team
answered on 30 Oct 2013, 09:54 AM
Hello Jason,

This issue is related with Excel and the way it is parsing the grid's values. When using HTML-Based Export format and the decimal separator is comma it is ignored by Excel and the value is represented as integer. You could try using a Biff export format where the decimal separator is recognized by the Excel no matter the sign, but in the exported file is always represented as dot.

Regards,
Kostadin
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
Jason
Top achievements
Rank 1
answered on 30 Oct 2013, 03:16 PM
Thank you for the reply. The information about the HTML output got me thinking about simply replacing the period decimal separator from the database with the appropriate decimal separator based on the language preference of the client's browser. Something like the sample below. Do you see anything wrong with this solution?


decimal lat = -33.85563;
e.Item.Cells[7].Text = lat.ToString().Replace(".", CultureInfo.GetCultureInfo(Request.UserLanguages[0]).NumberFormat.NumberDecimalSeparator.ToString());
0
Kostadin
Telerik team
answered on 04 Nov 2013, 11:43 AM
Hi Jason,

If you want to use HTML export format you have to replace the Culture format with a dot ".". In case you are using Biff format it is not neccesary to replace anything as the Excel will recognize the decimal separator and it will display it as a dot.

Regards,
Kostadin
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
Jason
Top achievements
Rank 1
answered on 04 Nov 2013, 02:49 PM
Once again thank you for the reply. Just to clarify, is the code below correct if I am using HTML export.
decimal lat = -33.85563;
e.Item.Cells[7].Text = lat.ToString().Replace(".", CultureInfo.GetCultureInfo(Request.UserLanguages[0]).NumberFormat.NumberDecimalSeparator.ToString());

0
Accepted
Kostadin
Telerik team
answered on 07 Nov 2013, 11:35 AM
Hi Jason,

You have to use the following approach. This way if the decimal separator is ",", it will be replaced with "." which is correctly recognized by Excel.
decimal lat = -33.85563;
e.Item.Cells[7].Text = lat.ToString().Replace(",", ".");

Regards,
Kostadin
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Grid
Asked by
Jason
Top achievements
Rank 1
Answers by
Kostadin
Telerik team
Jason
Top achievements
Rank 1
Share this question
or