protected void BtnAceptar_Click(object sender, EventArgs e) { if (FechaInicio.Text == "" || FechaFin.Text == "") { LbMensaje.Text = "Debe seleccionar fechas"; LbMensaje.Visible = true; } else { LbMensaje.Visible = false; DateTime FechaInicioReporte = DateTime.Parse(FechaInicio.Text); DateTime FechaFinReporte = DateTime.Parse(FechaFin.Text); ReporteBLL GestorReporte = new ReporteBLL(); List <ReporteDeVentasEntidad> ve = new List <ReporteDeVentasEntidad>(); ve = GestorReporte.ReporteEntreFechas(FechaInicioReporte, FechaFinReporte); ReportViewer1.LocalReport.DataSources.Clear(); ReportDataSource ds = new ReportDataSource("ReporteEntreFechas", ve); ReportViewer1.LocalReport.DataSources.Add(ds); ReportViewer1.ProcessingMode = ProcessingMode.Local; ReportViewer1.LocalReport.ReportPath = "Reportventas.rdlc"; ReportViewer1.LocalReport.Refresh(); } }
private void ExportarPDF() { if (FechaInicio.Text == "" || FechaFin.Text == "") { LbMensaje.Text = "Debe seleccionar fechas"; LbMensaje.Visible = true; } else { LbMensaje.Visible = false; DateTime FechaInicioReporte = DateTime.Parse(FechaInicio.Text); DateTime FechaFinReporte = DateTime.Parse(FechaFin.Text); ReporteBLL GestorReporte = new ReporteBLL(); List <ReporteDeVentasEntidad> ve = new List <ReporteDeVentasEntidad>(); Warning[] warnings; string[] streamIds; string contentType; string encoding; string extension; string deviceInfo = @"<DeviceInfo> <OutputFormat>EMF</OutputFormat> <PageWidth>8.5in</PageWidth> <PageHeight>11in</PageHeight> <MarginTop>0.25in</MarginTop> <MarginLeft>0.25in</MarginLeft> <MarginRight>0.25in</MarginRight> <MarginBottom>0.25in</MarginBottom> </DeviceInfo>"; ve = GestorReporte.ReporteEntreFechas(FechaInicioReporte, FechaFinReporte); ReportDataSource ds = new ReportDataSource("ReporteEntreFechas", ve); ReportViewer1.ProcessingMode = ProcessingMode.Local; ReportViewer1.LocalReport.ReportPath = "Reportventas.rdlc"; ReportViewer1.LocalReport.DataSources.Add(ds); ReportViewer1.LocalReport.Refresh(); //Export the RDLC Report to Byte Array. byte[] bytes = ReportViewer1.LocalReport.Render("PDF", deviceInfo, out contentType, out encoding, out extension, out streamIds, out warnings); //Download the RDLC Report in Word, Excel, PDF and Image formats. Response.Clear(); Response.Buffer = true; Response.Charset = ""; Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.ContentType = contentType; Response.AppendHeader("Content-Disposition", "attachment; filename=RDLC." + extension); Response.BinaryWrite(bytes); Response.Flush(); Response.End(); } }