0

See below code witch i am using

var workbook = new XLWorkbook();

        DataTable dts = Page.Session["inventorydata"] as DataTable;
        //*--------------------------------
        workbook.Worksheets.Add(dts, Type.ToLower());
        MemoryStream memorystream = new MemoryStream();
        workbook.SaveAs(memorystream);
        byte[] bytesInStream = memorystream.ToArray();
        memorystream.Close();
        Page.Response.ClearContent();
        Page.Response.ContentType = "application/force-download";
        Page.Response.AddHeader("content-disposition", "attachment;    filename=_Type_" + Type.ToLower() + "_" + DateTime.Now.ToShortDateString() + ".xlsx");
        Page.Response.BinaryWrite(bytesInStream);
        hdnIsdownload.Value = "true";
        
        //Page.Response.Write(workbook.ToString());
        Page.Response.Flush();
        Page.Response.End();
        Page.Response.Close();
        //isFileDownLoad = true;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.