Wel Sandhya.T simpliy create CSV file, following is a example code with static data make it dynamic
DataTable dt = new DataTable();
dt.Columns.Add("ID", typeof(int));
dt.Columns.Add("Name", typeof(string));
dt.AcceptChanges();
DataRow dr;
for (int i = 0; i < 5; i++)
{
dr = dt.NewRow();
dr[0] = i + 1;
dr[1] = "Name-" + (i + 1);
dt.Rows.Add(dr);
}
dt.AcceptChanges();
string Record="";
StreamWriter fileWriter = new StreamWriter("D:\\Data.csv");
fileWriter.WriteLine("ID,Name");
foreach(DataRow row in dt.Rows)
{
Record = "";
for (int j = 0; j < dt.Columns.Count;j++ )
Record += row[j].ToString() + ",";
fileWriter.WriteLine(Record);
}
fileWriter.Close();