locked
I need to do 3 copies of the same RDLC? HOW TO?? RRS feed

  • Question

  • User-448330226 posted

     Hi, i have a report (RDLC). I generate it with the control reportViewer, and in the code i use the next lines to generate it:

      

                  LocalReport localReport = new LocalReport();


                   .... LOAD DATASETS ...     


                    localReport.SubreportProcessing += new SubreportProcessingEventHandler(localReport_SubreportProcessing);
                    localReport.Refresh();

                    string reportType = "PDF";
                    string mimeType;
                    string encoding;
                    string fileNameExtension;

                    string deviceInfo = "<DeviceInfo>" + 
                   "  <OutputFormat>PDF</OutputFormat>" +
                   "  <PageWidth>8.2in</PageWidth>" +
                   "  <PageHeight>11.6in</PageHeight>" +
                   "  <MarginTop>0.4in</MarginTop>" +
                   "  <MarginLeft>0.4in</MarginLeft>" +
                   "  <MarginRight>0.4in</MarginRight>" +
                   "  <MarginBottom>0.4in</MarginBottom>" +
                   "</DeviceInfo>";

                    Warning[] warnings;
                    string[] streams;

                    byte[] renderedBytes;

                    //Render the report
                    localReport.ReportPath = Server.MapPath("~/reports/MAGRP_Total.rdlc");
                    renderedBytes = localReport.Render(reportType, deviceInfo, out mimeType, out encoding, out fileNameExtension, out streams, out warnings);

                    Response.Clear();
                    Response.ContentType = "application/pdf";
                    Response.AddHeader("content-disposition", "attachment; filename=" + ReportName + ".pdf");
                    Response.Charset = string.Empty;
                    Response.OutputStream.Write(renderedBytes , 0, renderedBytes .Length);
                    Response.Flush();
                    Response.Close();

     

    With this code, the report runs good. the problem is that I need to generate 3 copies of the same report. I have tried to concatenatex3 the renderedBytes,  by the result is a report with a size x 3, but with only the number of pages of 1 copy of the report.

    At the moment, I have a main report in which i have 3 reports (the same report x 3), but I think this is not the most efficient way to do it, because with this way i need to load the datasets of the subreports x 3.

    Anyone knows any way to do it more efficient? Only with 1 report but doing anything in the code which avoid to do more copies??

     

     

     

     

     

     

    Monday, September 8, 2008 1:36 PM

All replies

  • User-1396781667 posted
    Hi How about creating a 3 report viewers and adding the same rdlc file to them!! for (int i = 0; i < 4; i++)//as you need three reports { DataTable dtTable = new DataTable(); HtmlTableCell tblCell = new HtmlTableCell(); ReportViewer rptViewer = new ReportViewer(); //creating report viewer for each entity tblCell.Controls.Add(rptViewer); rowMain.Cells.Add(tblCell); //add this to the row of .aspx tblMain.Rows.Add(rowMain); rptViewer.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local; rptViewer.LocalReport.ReportPath = strReportPath; if (File.Exists(strReportPath)) { rptViewer.Height = Unit.Pixel(200); rptViewer.Width = Unit.Pixel(200); rptViewer.LocalReport.ReportEmbeddedResource = (Convert.ToString(strRDLCName) + ".rdlc"); rptViewer.LocalReport.DataSources.Clear(); if (objDataSet != null) //alots the datasource for dashboard { rptViewer.LocalReport.DataSources.Add(new ReportDataSource("DATASETNAME", objDataSet.Tables[i])); } } }
    Tuesday, September 9, 2008 1:03 AM
  • User-448330226 posted

    No, maybe i have not explained so good...

     I can do what you say, that is to say, something like next one:

    byte[] renderedBytes = null;

    byte[] renderedBytesAux = null;

    //Render the report

    localReport.ReportPath = Server.MapPath("~/reports/MAGRP_Total.rdlc");for (int i = 0; i < 3; i++)

    {

    renderedBytesAux = localReport.Render(reportType, deviceInfo,
    out mimeType, out encoding, out fileNameExtension, out streams, out warnings);  //

    renderedBytes = ConcatByte(renderedBytes, renderedBytesAux);  //ConcatBytes concat two Byte[]

    }

     It works good, BUT the problem is that the call  localReport.Render use a lot of time to process one copy of a report. So, I want to find any other way to do this one. Can I use only one time the call localReport.Render to generate 3 copies of the same report??

    I have tried the next code but as I said in my first post, the result is, curiously a report with a size multiplicate per 3, but it only has the pages of 1 report copy...

     renderedBytesAux = localReport.Render(reportType, deviceInfo, out mimeType, out encoding, out fileNameExtension, out streams, out warnings); 

    renderedBytes = ConcatByte(renderedBytes, renderedBytesAux);  //ConcatBytes concat two Byte[]

    renderedBytes = ConcatByte(renderedBytes, renderedBytesAux);  //ConcatBytes concat two Byte[]

     

    To summary, is it possible to use only one time the call localReport.Render to generate 3 copies of the same report??

     

     

     

    Tuesday, September 9, 2008 4:15 AM
  • User1586071711 posted

    I have tried the next code but as I said in my first post, the result is, curiously a report with a size multiplicate per 3, but it only has the pages of 1 report copy...

    Man this is so old but Im having the same problem...  Ordoin I hope you see this, did you find how to create a copy of the same RDLC?

    Friday, March 11, 2016 2:08 PM