Link to home
Start Free TrialLog in
Avatar of akohan
akohan

asked on

Writing numbers in text file (csv, excel)

Hello,

I'm writing some data into a text file as *.csv and one of the columns is credit card number. However, when it is opened in Excel its values is converted to scientific notation such as 4.54111E+15  (of course that is due to the format Excel assigns to cell containing this value) however, when I open it notepad or any ascii editor the value is normal.

How can I make it such that when Excel reads it still reads it as a normal number or string?

I tried:


sb.Append(String.Format("\"{0}\"", sCcNum.ToString() )

yet it still Excel shows it with scientific notation.

Thanks.
ASKER CERTIFIED SOLUTION
Avatar of AndyAinscow
AndyAinscow
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Try this:

sb.Append(String.Format("=\"{0}\"", sCcNum.ToString() )

Hi,
The best way for that was ="1234567890123". The = makes the cell a formula, and the quotation marks make the enclosed value an Excel string literal. This will display all the digits, even beyond Excel's numeric precision limit, but the cell (generally) won't be able to be used directly in numeric calculations.
Eventually got around to checking it - it is an apostrophe.  See attached pictures
0013.jpg
0014.jpg
Avatar of akohan
akohan

ASKER


Thanks to all.
Avatar of akohan

ASKER

This helped.
Thank you