I need to generate a Excel file in my webAPI in ASP.NET Core with the data received from a aurelia web app. The flow is this: In frontend I make the request
Print(printData: PrintData) {
return this.http
.fetch(`planning/Print`, {
method: "post",
body: json(printData)
})
.then(response => response.json())
.catch(error => {
console.log(error);
});
}
In web API Controller I get the data and generate the Excel file using the ClosedXML library
[HttpPost]
[Route("Print")]
public async Task<IActionResult> Print([FromBody] PrintDataVM data)
{
var getResponse = await mediator.Send(new PrintPlanning(data));
return Ok(getResponse);
public async Task<XLWorkbook> PrintPlanning(PrintDataVM data)
{
using (XLWorkbook workBook=new XLWorkbook())
{
var workSheet= workBook.Worksheets.Add("Horas");
workSheet.Cell("A1").Value = "Hola";
return workBook;
}
In my controller getResponse is this
and here my doubts begin because I don't know if I should get this obtejct or a memorystream. I do not know how to make the frontend get this so that once received I can treat it there. Right now this gives me error obviously
Any idea please?
Regards