public IActionResult GetReportTransportation(int TransportId) { try { var hasData = this.mapper.Map <TblTransportData, TransportDataViewModel>(this.repository.GetTblTransportDataWithKey(TransportId)); var onePage = new OnePage() { TemplateFolder = this.appEnvironment.WebRootPath + "\\reports\\" };//general class for work var stream = onePage.Export <TransportDataViewModel>(hasData, "ReportTransport"); stream.Seek(0, SeekOrigin.Begin); // "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "Reports.xlsx" // "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "Reports.docx" return(File(stream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "Reports.xlsx")); } catch (Exception ex) { return(NotFound(new { Error = "Transportation report not found " + ex.ToString() })); } }