I am trying to download Excel file using web API but I am unable to download file in postman where as I am able to download Excel file when I enter URL in browser though while opening file I get warning message like below :

[![enter image description here](https://i.stack.imgur.com/YSqoV.png)](https://i.stack.imgur.com/YSqoV.png)

[![enter image description here](https://i.stack.imgur.com/nsQve.png)](https://i.stack.imgur.com/nsQve.png)

[![enter image description here](https://i.stack.imgur.com/mEOEn.png)](https://i.stack.imgur.com/mEOEn.png)

When i hit endpoint using POSTMAN then file get corrupted and it is showing junk characters.

Code :

```
protected virtual byte[] ExportToXlsx<T>(IEnumerable<T> itemsToExport)
        {
            using (var stream = new MemoryStream())
            {
                using (var xlPackage = new ExcelPackage())
                {
                    // get handles to the worksheets
                    var worksheet = xlPackage.Workbook.Worksheets.Add(typeof(T).Name);

                    //create Headers and format them 
                    var manager = new PropertyManager<T>(itemsToExport.First());
                    manager.WriteCaption(worksheet, SetCaptionStyle);

                    var row = 2;

                    foreach (var items in itemsToExport)
                    {
                        manager.CurrentObject = items;
                        manager.WriteToXlsx(worksheet, row++, false);
                    }

                    xlPackage.Save();
                }
                return stream.ToArray();
            }
        }

private readonly IServiceContext ctx;
public void Download(string guid)
{
   var bytes = ExportToXlsx(list);
   ctx.reqobj.HttpContext.Response.Headers.Add("Content-Disposition", "attachment; filename=\"demo.xlsx\"");
   ctx.reqobj.HttpContext.Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
   ctx.reqobj.HttpContext.Response.Body.Write(bytes, 0, bytes.Length);
}

```

Note : I am using `OfficeOpenXml` for Excel file creation.

I will appreciate any help.

**Update :**
[![enter image description here](https://i.stack.imgur.com/YdArK.png)](https://i.stack.imgur.com/YdArK.png)