How to export csv file from asp.net website

Here is an example for simple code localized in button click on menegment function

protected void Button1_Click(object sender, EventArgs e)
{
Response.Clear();
Response.ContentType = “text/csv”;
Response.AddHeader(“content-disposition”, “attachment; filename = test.csv”);
for (int i = 0; i < 50; i++) { Response.Write("Value1, Value2, Value3\r\n"); } Response.End(); }

Leave a Reply

Your email address will not be published. Required fields are marked *