I have to create a API in dot net core which will return the excel as PDF. Excel works fine but when I try to send it in PDF content as you can see in the following code:
[HttpPost]
[Route("ExportToPdf")]
public IActionResult ExportToPdf()
{
MemoryStream stream = MyClassExcelWorkBook.GetExcel();
return File(stream, "application/pdf", "excel-Demo.pdf");
}
MyClassExcelWorkBook is a class where in GetExcel() will return MemoryStream of excel that has been created.
I have created the excel memory stream from epplus.core library that I have installed from NuGet. Can anyone help in creating the excel memory stream to pdf as response?