Advertisement
Guest User

Untitled

a guest
Oct 26th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. public void ExportReportCSV()
  2. {
  3. StringWriter sw = new StringWriter();
  4. sw.WriteLine(""Reference Number"");
  5. sw.WriteLine();
  6. Response.ClearContent();
  7. Response.AddHeader("content-disposition", "attachment;filename=Report" + DateTime.Now.ToString("yyyyMMddhhmmss") + ".csv");
  8. Response.ContentType = "application/octet-stream";
  9. Response.BinaryWrite(Encoding.UTF8.GetPreamble());
  10. sw.WriteLine(string.Format(""{0}"", "12345SDCRG"));
  11. Response.Write(sw.ToString());
  12. Response.End();
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement