5
I have a method that generates an excel file and writes it in a directory, but then I take the path of the directory and I need to download the excel file, but nothing occurs, no error. Can anyone help in what I’m failing?
[HttpGet]
public FileResult ObterDadosClientesBDO(ParametrosListaCliente filtro)
{
var jsonResult = Json(InstanceResolverFor<IServicoListaClientesBDO>.Instance.ObterDadosClientesBDO(filtro).ToArray(), JsonRequestBehavior.AllowGet);
jsonResult.MaxJsonLength = int.MaxValue;
string nomeRelatorio = string.Format("{0}{1}.xlsx","NOMERELATORIO", DateTime.Now.ToString("ddMMyyyyhhmmss"));
string caminhoRelatorio = GerarRelatorioExcel(jsonResult, nomeRelatorio);
return File(caminhoRelatorio, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", nomeRelatorio);
}
Have you tried switching to the second File parameter for "application/vnd.ms-excel"?
– George Wurthmann
I’ve done it, but on the same thing, nothing happens, no error on the console too.
– Renan Carvalho
Play the return of File in a Filecontentresult, check what it returns. If you want to put inside a Try/catch that will probably return the error. After that edit the result in your question.
– George Wurthmann