Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
I have a VB2010 programs that writes a tab delimited text file using
My.Computer.FileSystem.WriteAllText(TheFFn,S,False)

S contains a string of val[tab]val[tab][nl]val[tab]val[tab][nl]
i.e.
A B C
1 2 3
where spaces are tabs

This file is read by Excel later.

In the Excel the formatting is all off. The tabs are basically ignored.

Is there a default encode set someplace? Or what is the default encoding and what does Excel except.

This was done from the production Immediate Window
s = "A,B,C".Replace(",",t) & vbcrlf & "1,2,3".Replace(",",t)
? s
"A B C  1 2 3"
My.Computer.FileSystem.WriteAllText(ztemp & "xx.exl", s, False,System.Text.Encoding.ASCII) 


This shows in Excel as
ABC in Cell A1
123 in Cell A2
Tabs ignore and should have been put in different cells.

Does the default encoding change somehow? How can we check?
What is the default encoding if not specified?

What I have tried:

Using different encoding on the WriteAllText. Unicode seems to work but I really need to understand why the default encoding does not work.
Posted
Updated 3-Aug-16 5:38am

1 solution

Excel does not make assumptions about white space unless you import the file and tell it what delimiter you are using. If you want it to be automatic then use commas and save the file with a ".csv" extension.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900