0

We tried with the below code and cannot able to open in Microsoft Excel. Is this the right way to generate the .xlsb file using NPOI? Please advise

using (var exportdata = new MemoryStream())
                {
                    var name = output.xlsb;
                    System.Web.HttpContext.Current.Response.Clear();
                    workbook.Write(exportdata);                    
                    System.Web.HttpContext.Current.Response.ContentType = "application / vnd.ms - excel.sheet.binary.macroEnabled.12";
                    System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", string.Format("attachment;filename=" + name + ";"));
                    System.Web.HttpContext.Current.Response.BinaryWrite(exportdata.ToArray());
                    System.Web.HttpContext.Current.Response.Flush();
                    System.Web.HttpContext.Current.Response.End();
                }

0 Answers0