Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

EPPlus - no error but not creating Excel file either

$
0
0

Hi

I am using ASP.Net Core MVC with EPPlus to export to info to Excel.

It worked just fine until recently but now suddenly it doesn't create the Excel file but it also returns no error.
Stepping through in Debug reveals no problems and adding a try catch also catches no errors.

The code runs (when button is clicked on web page) but no Excel file is created .... any help how to fix or troubleshoot this?

        public IActionResult Export()
        {
            using (ExcelPackage pck = new ExcelPackage())
            {
                var demo = "Some sample text.";

                //Create the worksheet
                ExcelWorksheet ws = pck.Workbook.Worksheets.Add("Index");

                //Load the datatable into the sheet, starting from cell A1. Print the column names on row 1
                ws.Cells["A1"].LoadFromCollection(demo, true);

                //Write it back to the client
                Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
                Response.Headers.Add("content-disposition", "attachment;  filename=PropertiesExport.xlsx");

                var bytes = pck.GetAsByteArray();
                Response.Body.WriteAsync(bytes, 0, bytes.Length);
            }

            return View("Index");
        }


Viewing all articles
Browse latest Browse all 9386

Trending Articles



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