Quantcast
Channel: ClosedXML - The easy way to OpenXML
Viewing all articles
Browse latest Browse all 1877

New Post: How to download the generated file?

$
0
0
You'll have to save your workbook as a memorystream and write it to the HttpResponse. Something like this:
using (XLWorkbook wb = new XLWorkbook())
{
    // create your workbook here "MyWorkBook"

    // then send it to the http response...

    Response.Clear();
    Response.Buffer = true;
    Response.Charset = "";
    Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
    Response.AddHeader("content-disposition", "attachment;filename=Report.xlsx");

    using (MemoryStream ms = new MemoryStream())
    {
        MyWorkBook.SaveAs(ms);
        ms.WriteTo(Response.OutputStream);
        Response.Flush();
        Response.End();
    }
}

Viewing all articles
Browse latest Browse all 1877

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>