public async Task <HttpResponseMessage> GenerateClientsReport() { await ValidateToken(); var fileName = "RelatorioClientes_" + DateTime.Now.ToShortDateString().Replace("/", "-") + ".xlsx"; var reportData = _clientsService.GenerateClientsReport(); var response = new HttpResponseMessage(HttpStatusCode.OK) { Content = new ByteArrayContent(reportData) }; response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment") { FileName = fileName }; return(response); }