0

I have created an application in java language and I have used MySQL as a DBMS. I have a button in this application which export my data to .CSV file.

The problem is that when I open .CSV file, it automatically change the data. For example, 00001 will becomes 1.

How can I avoid automatically change data type in excel?

Enamul Hassan
  • 5,266
  • 23
  • 39
  • 56
hoger qassim
  • 37
  • 1
  • 9

4 Answers4

1

If you open the *.csv directly in Excel, then all columns will be read as type general (means there is an automated guessing for the value type).

If you import the file as text into the current sheet you can specify the value delimiter and also the type of each column.

SubOptimal
  • 22,518
  • 3
  • 53
  • 69
1

May be this is related. In that case the solution would be to save value as

"=""00001"""

This will be interpretered as text by excel.

Community
  • 1
  • 1
PKey
  • 3,715
  • 1
  • 14
  • 39
0

Have you tried prefixing it with a single quote?

Example: '00001

It's just a guess based on how that value would need to be typed into Excel for it to treat it as a string and not to convert the value into a numeric 1.

aresti
  • 1
  • 2
0

Another way that might work: when creating the csv, what value are you writing? Are you writing 0001 (so, as number); or "0001"?

You see, when this column is seen as number ... then it might be reasonable that you get 1 for 00001.

So, tried saving that the values for that column as "00001"?

GhostCat
  • 137,827
  • 25
  • 176
  • 248