boutique replica bags up ideas

the best replique rolex and prices here.

julia highlight 99j hair color 10a quality straight human hair lace front wigs 8 - 24 inches pre plucked hairline 13x4 inches lace front brazilian wig onlinefor sale

Export and Download Excel files with .NET Core

Updated on     Kisan Patel

How to Export and Download Excel files with .NET Core?

First, add the EPPlus into your project:

dotnet add package EPPlus

Now, generate the Excel file using EPPlus.

using OfficeOpenXml;
using System.IO;

namespace MyCMS.Controllers
{
   public class HomeController : ControllerBase
   {
      [HttpGet("export")]
      public async Task Export() {
            //fetch list using linq query
            var list = db.list.ToList();

            var stream = new MemoryStream();
            using (var package = new ExcelPackage(stream)) {
                var workSheet = package.Workbook.Worksheets.Add("sheetName");
                workSheet.Cells.LoadFromCollection(list, true);
                package.Save();
            };
            stream.Position = 0;
            var contentType = "application/octet-stream";
            var fileName = "fileName.xlsx";
            return File(stream, contentType, fileName);
      }

   }
}

.NET Core

Leave a Reply