1
Answer

How to change separator to write csv file using c#?

Photo of NJ  Bhanushali

NJ Bhanushali

9y
612
1

I have created CSV file using comma (,) separator using following code.

DataTable dt = dataSet.Tables[0]; 
StringBuilder csv = new StringBuilder();
for (int i = 0; i < dt.Rows.Count; i++)
{
for (int k = 0; k < dt.Columns.Count; k++)
{
csv.Append(dt.Rows[i][k].ToString() + ',');
}
csv.Append("\r\n");
}
File.WriteAllText(filePath, csv.ToString());

If I use comma, data divided into column properly. But when I try "|", it doesn't divide into columns
How can I change separator? I want to use "|" as a separator.

Answers (1)

0
Photo of Abhimanyu K Vatsa
NA 50.9k 12.4m 14y
I think you are asking about Visual Studio 2010. so there are lots of articles which explains step by step procedure to develop crystal reports, 

please read right side [Our recommended articles]
0
Photo of Mahesh Chand
2 286.9k 123.8m 14y
I am not sure if VB 2010 comes with the ReportViewer or not. You probably have to use Visual Studio 2010. You do not need any Crystal or other products to build reports using ReportViewer. This control is a Microsoft control.