afranka
05-09-2003, 10:57 AM
Hi,
I have created a c# script to create a csv file from a sql database.
Basically, it connects to and reads the data to a dataset which is then output through a streamwriter to create the csv.
Unfortunately the data includes some foreign names with text characters that display ok if I write them directly to the screen before sending to the file, but if I then open the file in Excel, the foreign characters come up as garbage.
I have solved this by the following:
StreamWriter sWriter = new StreamWriter(bufStream, Encoding.Unicode);
This seems to work ok on Office 2000, but on Office 97 I get an error: "The file is not a recognisable format".
It opens ok, but has "ÿþ" at the beginning of cell a1. I am guessing that this is part of the encoding. Please can anyone help with this?
Thanks!
I have created a c# script to create a csv file from a sql database.
Basically, it connects to and reads the data to a dataset which is then output through a streamwriter to create the csv.
Unfortunately the data includes some foreign names with text characters that display ok if I write them directly to the screen before sending to the file, but if I then open the file in Excel, the foreign characters come up as garbage.
I have solved this by the following:
StreamWriter sWriter = new StreamWriter(bufStream, Encoding.Unicode);
This seems to work ok on Office 2000, but on Office 97 I get an error: "The file is not a recognisable format".
It opens ok, but has "ÿþ" at the beginning of cell a1. I am guessing that this is part of the encoding. Please can anyone help with this?
Thanks!