Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Writing numbers in text file (csv, excel)

Posted on 2011-03-15
6
Medium Priority
?
1,272 Views
Last Modified: 2013-12-17
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.
0
Comment
Question by:akohan
6 Comments
 
LVL 45

Accepted Solution

by:
AndyAinscow earned 500 total points
ID: 35139384
If you aren't doing anything with the number then you could try to preface it with an apostrophe ' symbol.  (I think that is the correct one to force excel to treat it is a string rather than a number for display purposes.)
0
 
LVL 23

Expert Comment

by:wdosanjos
ID: 35143973
Try this:

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

0
 
LVL 11

Expert Comment

by:Sudhakar Pulivarthi
ID: 35148079
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.
0
NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

 
LVL 45

Expert Comment

by:AndyAinscow
ID: 35148207
Eventually got around to checking it - it is an apostrophe.  See attached pictures
0013.jpg
0014.jpg
0
 

Author Comment

by:akohan
ID: 35148296

Thanks to all.
0
 

Author Closing Comment

by:akohan
ID: 35148303
This helped.
Thank you
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Simulator games are perfect for generating sample realistic data streams, especially for learning data analysis. It is even useful for demoing offerings such as Azure stream analytics, PowerBI etc.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question