public IActionResult MonthlyReport() { try { Debug.WriteLine("Running sample 8"); var output = PrintOutInExcel.Run(); Debug.WriteLine("Sample 8 created: {0}", output); Debug.WriteLine(""); } catch (Exception ex) { Console.WriteLine("Error: {0}", ex.Message); } return(RedirectToAction("Dashboard", "Home")); }
public async Task <FileResult> DownloadFile(string fileName) { var output = PrintOutInExcel.Run(); var path = Path.Combine( Directory.GetCurrentDirectory(), "wwwroot\\DirFoeEx\\", "Power_consumption_report.xlsx"); var memory = new MemoryStream(); using (var stream = new FileStream(path, FileMode.Open)) { await stream.CopyToAsync(memory); } memory.Position = 0; return(File(memory, MediaTypeNames.Application.Octet, Path.GetFileName(path))); }