Asp.net - Output Excel Sheet from Memory Stream

This will allow the user to save the excel doc from the web.

        MemoryStream ms = new MemoryStream();
       //use whatever to save the excel workbook data to the memorystream

        byte[] array = ms.ToArray();  

        Response.Clear();
        Response.ContentType = "application/xlsx";
        Response.AddHeader("Content-Disposition", "attachment; filename=test.xlsx");
        Response.BinaryWrite(array);
        Response.Flush();
        Response.Close();
        Response.End();

Comments

Popular posts from this blog

Asp.net Publishing Broke Site - "App_WebReferences is not allowed because the application is precompiled"

Telerik - Custom Group Footers In RadGrid

Bootstrap Modal Popup is Grayed Out