writeto csv file

M

Mei Qin

Hello,

I have the following code to write each columns in a
datarow to the csv file:
myStreamWriter.Write(chr(34) & (myDr(I).ToString) & chr(34)
& ",")
I have a string field with the value of "000000". When I
open the file in Excel, the value displayed as "0". But I
really need to keep the way it is in the database. I tried
the following:
myStreamWriter.Write(chr(39) & (myDr(I).ToString) & ",")
It displayed as "'000000".
What should I do to display the value correctly in the CSV
file?

Thanks for any help!

Mei
 
R

Raterus

Are you sure the actual csv file is being outputted incorrectly? You said you opened it in excel, which will take your 000000 and make it into a 0 (that's just excel's problem), but if the csv file itself is ok, you are good to go. By the way, from a programming standpoint, always open csv files from a text editor, not excel, excel will change it around as you've found out!
 
M

Mei Qin

The customer need to open the CSV file in Excel, so they
can sort, filter on the data.
-----Original Message-----
Are you sure the actual csv file is being outputted
incorrectly? You said you opened it in excel, which will
take your 000000 and make it into a 0 (that's just excel's
problem), but if the csv file itself is ok, you are good
to go. By the way, from a programming standpoint, always
open csv files from a text editor, not excel, excel will
change it around as you've found out!
"Mei Qin" <[email protected]> wrote in
message news:[email protected]...
 
R

Raterus

Then in that case, you are probably going to need to surround all text values like this in quotes

"000000", "ABC", 45, 2837
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,007
Latest member
obedient dusk

Latest Threads

Top