1
my backend controller returns a file of type xlsx to my front, this is the method that makes the return:
public FileResult ListarLivrosExcel()
{
// Gerando minha planilha e recebendo-a
using (ExcelPackage arquivoExcel = new BmpoDTO().Gerar())
{
var stream = new MemoryStream();
arquivoExcel.SaveAs(stream);
// Mais sobre contentType: http://stackoverflow.com/questions/8166205/mime-type-for-excel-xml-asp-net-3-5
string contentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
string fileName = "Livros.xlsx";
stream.Position = 0;
return File(stream, contentType, fileName);
}
}
well, what I expected was that the browser would download the file in the xlsx format, however the download does not occur automatically.
debugging I can see the binaries of the return :
Is it possible to use JS to save these binaries ? or would have to force a browser download in xlsx format?
saved, however when opening the file, shows the binaries, edited the post and put a photo.
– alessandre martins