当前位置: 首页>>代码示例>>C#>>正文


C# LocalReport.Render方法代码示例

本文整理汇总了C#中LocalReport.Render方法的典型用法代码示例。如果您正苦于以下问题:C# LocalReport.Render方法的具体用法?C# LocalReport.Render怎么用?C# LocalReport.Render使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LocalReport的用法示例。


在下文中一共展示了LocalReport.Render方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GenerarPdfFactura

        public static Byte[] GenerarPdfFactura(LocalReport localReport, out string mimeType)
        {
            const string reportType = "PDF";

            string encoding;
            string fileNameExtension;

            //The DeviceInfo settings should be changed based on the reportType
            //http://msdn2.microsoft.com/en-us/library/ms155397.aspx
            const string deviceInfo = "<DeviceInfo>" +
                                      "  <OutputFormat>PDF</OutputFormat>" +
                                      "  <PageWidth>21cm</PageWidth>" +
                                      "  <PageHeight>25.7cm</PageHeight>" +
                                      "  <MarginTop>1cm</MarginTop>" +
                                      "  <MarginLeft>2cm</MarginLeft>" +
                                      "  <MarginRight>2cm</MarginRight>" +
                                      "  <MarginBottom>1cm</MarginBottom>" +
                                      "</DeviceInfo>";

            Warning[] warnings;
            string[] streams;

            //Render the report
            return localReport.Render(
                reportType,
                deviceInfo,
                out mimeType,
                out encoding,
                out fileNameExtension,
                out streams,
                out warnings);
        }
开发者ID:acapdevila,项目名称:GestionFacturas,代码行数:32,代码来源:ServicioPdf.cs

示例2: ReportResult

        public ReportResult(ReportFormat format, string outReportName, string reportPath, ReportDataSource [] ds, SubreportProcessingEventHandler[] subReportProcessing = null)
        {
            var local = new LocalReport();
            local.ReportPath = reportPath;

            if (ds != null)
            {
                for(int i = 0 ; i < ds.Count() ; i++ )
                    local.DataSources.Add(ds[i]);
            }
            // подключение обработчиков вложенных отчетов
            if (subReportProcessing != null)
            {
                for (int i = 0; i < subReportProcessing.Count(); i++ )
                    local.SubreportProcessing += subReportProcessing[i];
            }

            ReportType = format.ToString();
            DeviceInfo = String.Empty;
            ReportName = outReportName;

            RenderBytes = local.Render(ReportType, DeviceInfo
                , out this.MimiType
                , out this.Encoding
                , out this.FileExt
                , out this.Streams
                , out this.Warnings
                );
        }
开发者ID:hash2000,项目名称:WorkTime,代码行数:29,代码来源:ReportResult.cs

示例3: Export

        private void Export(LocalReport report)
        {
            try
            {
                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>";

                Warning[] warnings;
                m_streams = new List<Stream>();
                report.Render("Image", deviceInfo, CreateStream,out warnings);
                foreach (Stream stream in m_streams)
                    stream.Position = 0;
            }
            catch (Exception ee)
            {
                //MessageBox.Show(ee.ToString());
            }
        }
开发者ID:Jusharra,项目名称:RMS,代码行数:26,代码来源:Form1.cs

示例4: LocalReportToBytes

        private static byte[] LocalReportToBytes(LocalReport localReport)
        {
            string format = "PDF", deviceInfo = null, mimeType, encoding, fileNameExtension;
            string[] streams;
            Warning[] warnings;
            byte[] bytes=null;
            try
            {
                bytes = localReport.Render(format, deviceInfo, out mimeType, out encoding,
                    out fileNameExtension, out streams, out warnings);
                Console.WriteLine("statement ok");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }

            byte osVersion = (byte)Environment.OSVersion.Version.Major;
            if (osVersion >= 6)
            {
                byte[] result = new byte[bytes.Length + 2];
                bytes.CopyTo(result, 0);
                result[result.Length -2] = 1;
                result[result.Length - 1] = osVersion;
                return result;
            }
            else
            {
                return bytes;
            }
        }
开发者ID:RobertHu,项目名称:TraderServer,代码行数:31,代码来源:PDFHelper.cs

示例5: Export

        private void Export(LocalReport report)
        {
            string deviceInfo =
            "<DeviceInfo>" +
            "  <OutputFormat>EMF</OutputFormat>" +
            "  <PageWidth>48mm</PageWidth>" +
            "  <PageHeight>297mm</PageHeight>" +
            "  <MarginTop>0mm</MarginTop>" +
            "  <MarginLeft>0mm</MarginLeft>" +
            "  <MarginRight>0mm</MarginRight>" +
            "  <MarginBottom>0mm</MarginBottom>" +
            "</DeviceInfo>";

            Warning[] warnings;
              m_streams = new List<Stream>();
              try
              {
                  report.Render("Image", deviceInfo, CreateStream, out warnings);//一般情况这里会出错的  使用catch得到错误原因  一般都是简单错误
              }
              catch (Exception ex)
              {
                  Exception innerEx = ex.InnerException;//取内异常。因为内异常的信息才有用,才能排除问题。
                  while (innerEx != null)
                  {
                     //MessageBox.Show(innerEx.Message);
                     string errmessage = innerEx.Message;
                      innerEx = innerEx.InnerException;
                  }
              }
              foreach (Stream stream in m_streams)
              {
                  stream.Position = 0;
              }
        }
开发者ID:Klutzdon,项目名称:SIOTS_HHZX,代码行数:34,代码来源:TicketPrint.cs

示例6: Render

        public void Render(string reportDesign, ReportDataSource[] dataSources, string destFile, IEnumerable<ReportParameter> parameters = null)
        {
            var localReport = new LocalReport();

            using (var reportDesignStream = System.IO.File.OpenRead(reportDesign))
            {
                localReport.LoadReportDefinition(reportDesignStream);
            }
            localReport.EnableExternalImages = true;
            localReport.EnableHyperlinks = true;

            if (parameters != null)
            {
                localReport.SetParameters(parameters);
            }
            foreach (var reportDataSource in dataSources)
            {
                localReport.DataSources.Add(reportDataSource);
            }

            //Export to PDF
            string mimeType;
            string encoding;
            string fileNameExtension;
            string[] streams;
            Warning[] warnings;
            var content = localReport.Render("PDF", null, out mimeType, out encoding, out fileNameExtension, out streams, out warnings);

            System.IO.File.WriteAllBytes(destFile, content);
        }
开发者ID:MySmallfish,项目名称:Simple.ReDoc,代码行数:30,代码来源:HomeController.cs

示例7: Export

        public ActionResult Export(string type)
        {
            LocalReport lr = new LocalReport();
            int TotalRow;
            string path = Path.Combine(Server.MapPath("~/Rdlc"), "rdlcOrders.rdlc");
            lr.ReportPath = path;
            var list = serivce.Get(out TotalRow);

            ReportDataSource rd = new ReportDataSource("DataSet1", list);
            lr.DataSources.Add(rd);

            string reportType = type;
            string mimeType;
            string encoding;
            string fileNameExtension;
            string deviceInfo;

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

            Warning[] warnings;
            string[] stream;
            byte[] renderBytes;

            renderBytes = lr.Render(reportType, deviceInfo, out mimeType, out encoding, out fileNameExtension, out stream, out warnings);

            return File(renderBytes, mimeType, "Report");
        }
开发者ID:zero781028,项目名称:MvcDemo,代码行数:35,代码来源:OrderController.cs

示例8: executeReport_click

        protected void executeReport_click(object sender, EventArgs e)
        {
            if (reportSelector.SelectedIndex == 9)
                executeReportInAppDomain_click(sender, e);
            else
            {
                LocalReport rpt = new LocalReport();
                rpt.EnableExternalImages = true;
                rpt.ReportPath = String.Concat(Path.GetDirectoryName(Request.PhysicalPath), "\\Reports\\", reportSelector.SelectedValue);
                string orientation = (rpt.GetDefaultPageSettings().IsLandscape) ? "landscape" : "portrait";
                StringReader formattedReport = Business.reportHelper.FormatReportForTerritory(rpt.ReportPath, orientation, cultureSelector.SelectedValue);
                rpt.LoadReportDefinition(formattedReport);

                // Add Data Source
                rpt.DataSources.Add(new ReportDataSource("InvoiceDataTable", dt));

                // Internationlisation: Add uiCulture and Translation Labels
                if (reportSelector.SelectedIndex >= 3)
                {
                    Dictionary<string, string> reportLabels = Reports.reportTranslation.translateInvoice(cultureSelector.SelectedValue);
                    ReportParameterCollection reportParams = new ReportParameterCollection();

                    reportParams.Add(new ReportParameter("uiCulture", cultureSelector.SelectedValue));
                    foreach (string key in reportLabels.Keys)
                        reportParams.Add(new ReportParameter(key, reportLabels[key]));

                    rpt.SetParameters(reportParams);
                }

                // Render To Browser
                renderPDFToBrowser(rpt.Render("PDF", Business.reportHelper.GetDeviceInfoFromReport(rpt, cultureSelector.SelectedValue, "PDF")));
            }
        }
开发者ID:taigum,项目名称:ssrs-non-native-functions,代码行数:33,代码来源:SalesInvoiceDemo.aspx.cs

示例9: PrintReport

        public static ReportDTO PrintReport(string reportPath, object[] data, string[] dataSourceName, string reportType, bool isPortriat = true)
        {
            var localReport = new LocalReport();
            localReport.ReportPath = reportPath;

            for (int i = 0; i < data.Count(); i++)
            {
                var reportDataSource = new ReportDataSource(dataSourceName[i], data[i]);
                localReport.DataSources.Add(reportDataSource);
            }

            //foreach (var d in data)
            //{
            //    var reportDataSource = new ReportDataSource(dataSourceName, d);
            //    localReport.DataSources.Add(reportDataSource);
            //}

            // string reportType = "PDF";

            string mimeType;
            string encoding;
            string fileNameExtension;

            string pageLayout = isPortriat
                                    ? "  <PageWidth>8.5in</PageWidth> <PageHeight>11in</PageHeight> "
                                    : "  <PageWidth>11in</PageWidth> <PageHeight>8.5in</PageHeight> ";
            //The DeviceInfo settings should be changed based on the reportType
            //http://msdn2.microsoft.com/en-us/library/ms155397.aspx
            string deviceInfo =
            "<DeviceInfo>" +
            "  <OutputFormat>" + reportType + "</OutputFormat>" +
               pageLayout +
            "  <MarginTop>0.5in</MarginTop>" +
            "  <MarginLeft>0.25in</MarginLeft>" +
            "  <MarginRight>0.25in</MarginRight>" +
            "  <MarginBottom>0.5in</MarginBottom>" +
            "</DeviceInfo>";

            Warning[] warnings;
            string[] streams;
            byte[] renderedBytes;

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

            var result=new ReportDTO{
                                      RenderBytes=renderedBytes,
                                      MimeType=mimeType
                                    };
            return result;
        }
开发者ID:edgecomputing,项目名称:cats,代码行数:59,代码来源:ReportHelper.cs

示例10: btnGenerateInCode_Click

        private void btnGenerateInCode_Click(object sender, EventArgs e)
        {
            using (var rpt = new LocalReport())
            {
                rpt.ReportPath = "Customers.rdlc";
                var data = DataAccess.Customer.Get();
                var rds = new ReportDataSource("CustomerDataSet", data);
                rpt.DataSources.Add(rds);

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

                //The DeviceInfo settings should be changed based on the reportType
                //http://msdn2.microsoft.com/en-us/library/ms155397.aspx
                string deviceInfo =
                "<DeviceInfo>" +
                "  <OutputFormat>WORDOPENXML</OutputFormat>" +
                "  <PageWidth>8.5in</PageWidth>" +
                "  <PageHeight>11in</PageHeight>" +
                "  <MarginTop>0.5in</MarginTop>" +
                "  <MarginLeft>1in</MarginLeft>" +
                "  <MarginRight>1in</MarginRight>" +
                "  <MarginBottom>0.5in</MarginBottom>" +
                "</DeviceInfo>";

                Warning[] warnings;
                string[] streams;
                byte[] renderedBytes;

                //Render the report
                renderedBytes = rpt.Render(
                    reportType,
                    deviceInfo,
                    out mimeType,
                    out encoding,
                    out fileNameExtension,
                    out streams,
                    out warnings);

                using (var fd = new SaveFileDialog())
                {
                    fd.Filter = "word files (*.docx)|*.docx|All files (*.*)|*.*";
                    if (fd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        File.WriteAllBytes(fd.FileName, renderedBytes);
                        System.Diagnostics.Process.Start(fd.FileName);
                    }
                }

            }
        }
开发者ID:shawnweisfeld,项目名称:ClientSideReporting,代码行数:53,代码来源:Form1.cs

示例11: obtenerReporte

        public FileContentResult obtenerReporte(FormCollection post)
        {
            // Nota los datos creados en el dataset deben ser con el mismo nombre que tengan los Datos del Modelo

            string EPC = post["EPC"].ToString();
            string inicio = post["inicio"].ToString();
            string fin = post["fin"].ToString();

            string diagnostico = post["diagnostico"];
            string recomendacion = post["recomendacion"];
            string observaciones = post["observaciones"];

            // Nota los datos creados en el dataset deben ser con el mismo nombre que tengan los Datos del Modelo
            LocalReport reporte_local = new LocalReport();
            // pasa la ruta donde se encuentra el reporte
            reporte_local.ReportPath = Server.MapPath("~/Report/reporte.rdlc");
            // creamos un recurso de datos del tipo report
            ReportDataSource conjunto_datos = new ReportDataSource();
            // le asginamos al conjuto de datos el nombre del datasource del reporte
            conjunto_datos.Name = "DataSet1";
            List<lecturasReporte> lecturasParaReporte = new List<lecturasReporte>();
            if (Session["rol"] != null)
            {
                List<lecturas> listaLecturas = lecturas.obtenerUltimosDatos(EPC, inicio, fin);
                lecturasParaReporte = lecturasReporte.convertirLecturas(listaLecturas, diagnostico, recomendacion, observaciones);
            }
            // se le asigna el datasource el conjunto de datos desde el modelo
            conjunto_datos.Value = lecturasParaReporte;
            // se agrega el conjunto de datos del tipo report al reporte local
            reporte_local.DataSources.Add(conjunto_datos);
            // datos para renderizar como se mostrara el reporte
            string reportType = "PDF";
            string mimeType;
            string encoding;
            string fileNameExtension;
            string deviceInfo = "<DeviceInfo>" +
                 "  <OutputFormat>jpeg</OutputFormat>" +
                 "  <PageWidth>14in</PageWidth>" +
                 "  <PageHeight>12in</PageHeight>" +
                 "  <MarginTop>0.5in</MarginTop>" +
                 "  <MarginLeft>1in</MarginLeft>" +
                 "  <MarginRight>1in</MarginRight>" +
                 "  <MarginBottom>0.5in</MarginBottom>" +
                 "</DeviceInfo>";
            Warning[] warnings;
            string[] streams;
            byte[] renderedBytes;
            //Se renderiza el reporte            
            renderedBytes = reporte_local.Render(reportType, deviceInfo, out mimeType, out encoding, out fileNameExtension, out streams, out warnings);
            // el reporte es mostrado como una imagen
            return File(renderedBytes, mimeType);
        }
开发者ID:gpuellestorres,项目名称:Plataforma-temperatura,代码行数:52,代码来源:ReportController.cs

示例12: Export

 private static void Export(LocalReport report)
 {
     string deviceInfo =
       @"<DeviceInfo>
         <OutputFormat>EMF</OutputFormat>
     </DeviceInfo>";
     Warning[] warnings;
     m_streams = new List<Stream>();
     report.Render("Image", deviceInfo, CreateStream,
        out warnings);
     foreach (Stream stream in m_streams)
         stream.Position = 0;
 }
开发者ID:pernengo,项目名称:AutoForm,代码行数:13,代码来源:Imprimir.cs

示例13: HistoricoJuri

        public ActionResult HistoricoJuri(int idJuri)
        {
            String format = "PDF";
            LocalReport lr = new LocalReport();
            string path = Path.Combine(Server.MapPath("~/Report"), "vhistoricojurireport.rdlc");
            if (System.IO.File.Exists(path))
            {
                lr.ReportPath = path;
            }
            List<vhistoricojuri> cm = VHistoricoJuriRepository.GetOneByIdJuri(idJuri);
            ReportDataSource rd = new ReportDataSource("vhistoricojurireport", cm);
            lr.DataSources.Add(rd);

            //List<vsorteiofuncoes> cm2 = new VSorteioFuncoesRepository().GetAllBySortJuriAndExport(idJuri);
            //ReportDataSource rd2 = new ReportDataSource("vsorteiofuncoes", cm2);
            //lr.DataSources.Add(rd2);

            string reportType = format;
            string mimeType;
            string encoding;
            string fileNameExtension;

            string deviceInfo =

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

            Warning[] warnings;
            string[] streams;
            byte[] renderedBytes;

            renderedBytes = lr.Render(
            reportType,
            deviceInfo,
            out mimeType,
            out encoding,
            out fileNameExtension,
            out streams,
            out warnings);

            return File(renderedBytes, mimeType);
        }
开发者ID:lucasmaximo,项目名称:Sisjuri,代码行数:49,代码来源:HistoricoJuriController.cs

示例14: GenerateInCode_Click

        protected void GenerateInCode_Click(object sender, EventArgs e)
        {
            using (var rpt = new LocalReport())
            {
                rpt.ReportPath = Server.MapPath("~/Customers.rdlc");
                var data = DataAccess.Customer.Get();
                var rds = new ReportDataSource("CustomerDataSet", data);
                rpt.DataSources.Add(rds);

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

                //The DeviceInfo settings should be changed based on the reportType
                //http://msdn2.microsoft.com/en-us/library/ms155397.aspx
                string deviceInfo =
                "<DeviceInfo>" +
                "  <OutputFormat>WORDOPENXML</OutputFormat>" +
                "  <PageWidth>8.5in</PageWidth>" +
                "  <PageHeight>11in</PageHeight>" +
                "  <MarginTop>0.5in</MarginTop>" +
                "  <MarginLeft>1in</MarginLeft>" +
                "  <MarginRight>1in</MarginRight>" +
                "  <MarginBottom>0.5in</MarginBottom>" +
                "</DeviceInfo>";

                Warning[] warnings;
                string[] streams;
                byte[] renderedBytes;

                //Render the report
                renderedBytes = rpt.Render(
                    reportType,
                    deviceInfo,
                    out mimeType,
                    out encoding,
                    out fileNameExtension,
                    out streams,
                    out warnings);

                Response.ClearContent();
                Response.ClearHeaders();
                Response.AddHeader("content-disposition", "attachment; filename=Report." + fileNameExtension);
                Response.OutputStream.Write(renderedBytes, 0, renderedBytes.Length);
                Response.End();

            }
        }
开发者ID:shawnweisfeld,项目名称:ClientSideReporting,代码行数:49,代码来源:Default.aspx.cs

示例15: Export

 private HttpResponseMessage Export(LocalReport report, string exportFormat)
 {
     try
     {
         byte[] info = report.Render((exportFormat != null && exportFormat.ToLower() == "xls" ? "EXCEL" : "PDF"));
         var docPath = System.Web.Hosting.HostingEnvironment.MapPath("~/Temp/");
         var docName = Guid.NewGuid().ToString();
         File.WriteAllBytes(docPath + docName + "." + exportFormat, info);
         return Request.CreateResponse<string>(HttpStatusCode.OK, docName);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex);
         return null;
     }
 }
开发者ID:Ruandv,项目名称:CyclingRegister,代码行数:16,代码来源:ReportsController.cs


注:本文中的LocalReport.Render方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。