private void ShowReport() { relatorio.Reset(); var dataTableProjetos = new ListaHospedeTableAdapter(); var dataSetProjetos = new ListaHospede.ListaHospedeDataTable(); dataTableProjetos.Fill(dataSetProjetos); var listaProjetos = dataSetProjetos.Select(); var dtsProjetos = new ReportDataSource("DataSet1", listaProjetos); relatorio.LocalReport.DataSources.Add(dtsProjetos); relatorio.LocalReport.ReportPath = Server.MapPath("Relatorios\\ListaHospedeReport.rdlc"); relatorio.ShowPrintButton = true; relatorio.LocalReport.Refresh(); }
public ActionResult RelatorioListaHospede() { try { ReportViewer relatorio = new ReportViewer(); relatorio.ProcessingMode = ProcessingMode.Local; relatorio.LocalReport.ReportPath = Server.MapPath("~\\Relatorios\\ListaHospedeReport.rdlc"); relatorio.LocalReport.Refresh(); var dataTableProjetos = new ListaHospedeTableAdapter(); var dataSetProjetos = new ListaHospede.ListaHospedeDataTable(); dataTableProjetos.Fill(dataSetProjetos); var listaProjetos = dataSetProjetos.Select(); var dtsProjetos = new ReportDataSource("DataSet1", listaProjetos); relatorio.LocalReport.DataSources.Add(dtsProjetos); relatorio.ShowPrintButton = true; relatorio.LocalReport.Refresh(); string reportType = "PDF"; string mimeType; string encoding; string fileNameExtension; string deviceInfo = "<DeviceInfo>" + " <OutputFormat>PDF</OutputFormat>" + " <PageWidth>12in</PageWidth>" + " <PageHeight>9in</PageHeight>" + " <MarginTop>0.2in</MarginTop>" + " <MarginLeft>.7in</MarginLeft>" + " <MarginRight>.8in</MarginRight>" + " <MarginBottom>0.2in</MarginBottom>" + "</DeviceInfo>"; Warning[] warnings; string[] streams; byte[] bytes; //Renderiza o relatório em bytes bytes = relatorio.LocalReport.Render( reportType, deviceInfo, out mimeType, out encoding, out fileNameExtension, out streams, out warnings); return File(bytes, mimeType); } catch (Exception ex) { return null; } }