Models: public class UserInfo { public string UserName { get; set; } public int Age { get; set; } } public class DemoResponse { public int Code { get; set; } public string Msg { get; set; } public T Data { get; set; } public static DemoResponse GetResult(int code, string msg, T data = default(T)) { return new DemoResponse { Code = code, Msg = msg, Data = data }; } } Download view page: DownLoad.cshtml: @page "/download" @model BlazorServerApp.Pages.DownloadModel @{ } Download.cshtml.cs: using BlazorServerApp.Data; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; using OfficeOpenXml; namespace BlazorServerApp.Pages { public class DownloadModel : PageModel { public IActionResult OnGet() { //queryt the data dabtase and get the data. var list = new List() { new UserInfo { UserName = "catcher", Age = 18 }, new UserInfo { UserName = "james", Age = 20 }, }; // If you use EPPlus in a noncommercial context // according to the Polyform Noncommercial license: ExcelPackage.LicenseContext = LicenseContext.NonCommercial; var stream = new MemoryStream(); using (var package = new ExcelPackage(stream)) { var workSheet = package.Workbook.Worksheets.Add("Sheet1"); workSheet.Cells.LoadFromCollection(list, true); package.Save(); } stream.Position = 0; string excelName = $"UserList-{DateTime.Now.ToString("yyyyMMddHHmmssfff")}.xlsx"; //return File(stream, "application/octet-stream", excelName); return File(stream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", excelName); } } }