Click here to Skip to main content
15,172,951 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
Plz help me.

send me the above coding and give deep explanation about that code.
Updated 24-Sep-11 1:14am

thank u for giving me the answer.

what is the use of these two statements in the above code?

AcceptChanges() and why we took the Record Var is an empty?

Adding the column names by dynamically to that file?

i know that CSV is a Comma Separated Values, but i don't know how it looks like, again i have to write code for converting it to an excel file?
André Kraak 11-Oct-11 6:50am
If you have a question about or comment on a given solution use the "Have a Question or Comment?" option beneath the solution. When using this option the person who gave the solution gets an e-mail message and knows you placed a comment and can respond if he/she wants.

Please move the content of this solution to the solution you are commenting on and remove the solution.
Thank you.
Have a look at this article Writing Data from a DataTable to Excel[^].
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));
            DataRow dr;
            for (int i = 0; i < 5; i++)
                dr = dt.NewRow();
                dr[0] = i + 1;
                dr[1] = "Name-" + (i + 1);
            string Record="";
            StreamWriter fileWriter = new StreamWriter("D:\\Data.csv");
            //Insert Headers
            foreach(DataRow row in dt.Rows)
                Record = "";
                for (int j = 0; j < dt.Columns.Count;j++ )
                    Record += row[j].ToString() + ",";

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