13 Programación Web con .NET y C#

8
REPORTES ASP.NET Guido Ticona Hurtado [email protected]

Transcript of 13 Programación Web con .NET y C#

Page 1: 13 Programación Web con .NET y C#

REPORTESASP.NET

Guido Ticona [email protected]

Page 2: 13 Programación Web con .NET y C#

Crystal Reports Referencias

CrystalDecisions.SharedCrystalDecisions.ReportSourceCrystalDecisions.CrystalReports.Engine

Page 3: 13 Programación Web con .NET y C#

Crystal Reports (Cont.)ReportClass rpt = new ReportClass();rpt.FileName = Server.MapPath("report.rpt");rpt.Load();rpt.SetDataSource(db.PERSONAS);Stream stream = rpt.ExportToStream(

CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);

return File(stream, "application/pdf");   

Page 4: 13 Programación Web con .NET y C#

Crystal Reports (Cont.) Parametros

rpt.SetParameterValue(“p",“valor");

Page 5: 13 Programación Web con .NET y C#

RPLCLocalReport reporte= new LocalReport();reporte.ReportPath = "Reports/Report1.rdlc";ReportDataSource reportDataSource =

new ReportDataSource("DataSet1", db);reporte.DataSources.Add(reportDataSource);

Page 6: 13 Programación Web con .NET y C#

RDLC (Cont.)string deviceInfo =

"<DeviceInfo>" +" <OutputFormat>PDF</OutputFormat>" +" <PageWidth>8.5in</PageWidth>" +" <PageHeight>11in</PageHeight>" +" <MarginTop>0.5in</MarginTop>" +" <MarginLeft>1in</MarginLeft>" +" <MarginRight>1in</MarginRight>" +" <MarginBottom>0.5in</MarginBottom>" +"</DeviceInfo>";

Page 7: 13 Programación Web con .NET y C#

RDLC (Cont.)byte[] renderedBytes = reporte.Render(

reportType,deviceInfo,out mimeType,out encoding,out fileNameExtension,out streams, //string[]out warnings); //Warning[]

return File(renderedBytes, mimeType);

Page 8: 13 Programación Web con .NET y C#

RDLC (Cont.) Referencias

Microsoft.ReportViewer.WebForms Parámetros

reporte.SetParameters(new ReportParameter(“p",“valor"));

Descargar ArchivoResponse.AddHeader("content-disposition",

"attachment; filename=reporte." + fileNameExtension);