1

I use the following map in my java class

Map<String,String> fieldNameMap=new LinkedHashMap<String,String>();
     fieldNameMap.put("provLocation", "Location");
     fieldNameMap.put("deviceOwnerTn","Owner Telephone Number");

which i make available as a csv download. However in the case of the second item, when the number exceeds 5 or 6 digits, it shows up in excel with exponential formatting(eg. 1.235E+09). I want to avoid this. One possible solution was to enclose it in single quotes.(eg.'1234567890'). But how do i go about it? Please help!

NOTE: For fieldNameMap, the first parameter is the value to be populated and the second parameter is the column heading.

Bharath Naidu
  • 195
  • 3
  • 6
  • 14
  • How do you output the number to the file? Is it in exponential format in the CSV file. Side note, you probably do not want to use a number for phone numbers, but rather a string as you will otherwise get problems with phone numbers starting with 0. – Roger Lindsjö Sep 28 '12 at 07:52
  • Thanks Roger, but i am using it as a string. I am outputting it in the normal decimal format. – Bharath Naidu Sep 28 '12 at 08:02

1 Answers1

0

As I understand it the output in the CSV is the way you want it (without exponent) but Excel displays it in a format you don't want.

The problem is that Excel tries to be smart and guess the type of the field, and an all number field is a "number" and by default it is shown in exponential (scientific) format.

See Excel CSV - Number Cell Format, there are some really good answers.

Community
  • 1
  • 1
Roger Lindsjö
  • 11,330
  • 1
  • 42
  • 53