Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Ennija 44 posts 126 karma points
    Sep 08, 2015 @ 09:37
    Ennija
    0

    form export to excel

    why excel return csv format? I need xlsx format. How can change format? With csv format in excel data looks like this enter image description here

  • Samira 113 posts 452 karma points
    Sep 08, 2015 @ 10:54
    Samira
    2

    Hi,

    Use the response object

    HttpContext.Current.Response.Clear();
                    HttpContext.Current.Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
                    HttpContext.Current.Response.AddHeader("Content-Disposition", "ReportResult.xlsx");
                    HttpContext.Current.Response.BinaryWrite(pck.GetAsByteArray());
                    HttpContext.Current.Response.End();
    

    Grazitti

Please Sign in or register to post replies

Write your reply to:

Draft