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


C# ReportViewer类代码示例

本文整理汇总了C#中ReportViewer的典型用法代码示例。如果您正苦于以下问题:C# ReportViewer类的具体用法?C# ReportViewer怎么用?C# ReportViewer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: Main

        static void Main(string[] args)
        {
            var connectionString = TestTaskConfiguration.Instance.ConnectionString;
            var context = new DataContext(connectionString);
            var repository = new EmployeeRepository(context);
            var service = new EmployeeService(repository);

            var node = new EmployeeReportModel();

            node.EmployeeDetails = service.All().OrderBy(x => x.FirstName).Select(x => new EmployeeReportDetailsModel
            {
                Name = x.FirstName,
                Wage = x.Wage
            }).ToList();

            dataList.Add(node);

            ReportViewer reportViewer = new ReportViewer();
            reportViewer.ProcessingMode = ProcessingMode.Local;
            reportViewer.LocalReport.ReportPath = AppDomain.CurrentDomain.BaseDirectory + @"\..\..\EmployeeReportTemplate.rdlc";
            reportViewer.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(ReportViewer_OnSubreportProcessing);
            reportViewer.LocalReport.DataSources.Add(new ReportDataSource("DSEmployee", dataList));

            Byte[] result = reportViewer.LocalReport.Render("PDF");

            using (FileStream fs = new FileStream(AppDomain.CurrentDomain.BaseDirectory + @"\Test.pdf", FileMode.OpenOrCreate, FileAccess.Write, FileShare.Write))
            {
                fs.Write(result, 0, result.Length);
                fs.Flush();
                fs.Close();
            }

            //Console.ReadKey();
        }
开发者ID:SenkaOlefir,项目名称:TestTask-Murano,代码行数:34,代码来源:Program.cs

示例2: ExportarXLS

        protected void ExportarXLS()
        {
            ReportViewer rvExporter = new ReportViewer();

            rvExporter.ProcessingMode = ProcessingMode.Local;
            rvExporter.LocalReport.ReportPath = Server.MapPath(@"~\Reports\ListadeCompras.rdlc");
            rvExporter.LocalReport.DataSources.Add(new ReportDataSource("Lista", GetDados()));
            rvExporter.LocalReport.Refresh();

            Resultado resultado = new Resultado();
            Ped_ItemFacade oPedFacade = new Ped_ItemFacade();

            int CategoriaID = Convert.ToInt32(Request.QueryString["categoriaid"]);
            int CC_ID = Convert.ToInt32(Request.QueryString["CC"]);
            resultado = new Ped_ItemFacade().AtualizaProcessoCompra(CategoriaID, CC_ID);

            ////Exportar para PDF
            string mimeType;
            string encoding;
            string fileNameExtension;
            Warning[] warnings;
            string[] streamids;
            byte[] exportBytes = rvExporter.LocalReport.Render("Excel", null, out mimeType, out encoding, out fileNameExtension, out streamids, out warnings);

            Response.Buffer = true;
            Response.Clear();
            Response.ContentType = mimeType;
            Response.AddHeader("content-disposition", string.Format("attachment;filename={0}.{1}",  DateTime.Now.ToString("yyyy-MM-dd") + "Planilha Processo de Compra Numero " + resultado.Id.ToString().PadLeft(6,'0') , fileNameExtension));
            Response.BinaryWrite(exportBytes);
            Response.Flush();
            Response.End();

            rvExporter.Dispose();
        }
开发者ID:ViniciusConsultor,项目名称:controle-compras,代码行数:34,代码来源:PedidosListaItem.aspx.cs

示例3: GetReport

        /*ActionResult*/
        public void GetReport(string name)
        {
            ReportViewer reportViewer = new ReportViewer();
            try
            {

                var reportUri = System.Configuration.ConfigurationManager.AppSettings["reportServerUri"];
                var reportUser = System.Configuration.ConfigurationManager.AppSettings["reportUserName"];
                var reportUserPass = System.Configuration.ConfigurationManager.AppSettings["reportUserPass"];
                var reportUserDomain = System.Configuration.ConfigurationManager.AppSettings["reportUserDomain"];
                reportViewer.ProcessingMode = ProcessingMode.Remote;
                reportViewer.SizeToReportContent = true;
                reportViewer.Width = System.Web.UI.WebControls.Unit.Percentage(100);
                reportViewer.Height = System.Web.UI.WebControls.Unit.Percentage(100);
                reportViewer.ServerReport.ReportServerCredentials = new Security.ReportServerCredentials(reportUser, reportUserPass, reportUserDomain);
                reportViewer.CssClass = "reportViewer";
                reportViewer.ShowToolBar = true;
                reportViewer.ShowParameterPrompts = true;
                reportViewer.ShowExportControls = true;
                reportViewer.AsyncRendering = true;
                reportViewer.ServerReport.ReportPath = String.Format("/{0}", name);
                reportViewer.ServerReport.ReportServerUrl = new Uri(reportUri);
            }
            catch (ReportViewerException rvex)
            {
                throw new Exception(String.Format("reviewer error {0}", rvex.Message));
            }
            ViewBag.ReportViewer = reportViewer;
        }
开发者ID:MedicalTeams,项目名称:Hip_Admin,代码行数:30,代码来源:ReportController.cs

示例4: GeneratePDF

        public static Task GeneratePDF(List<Contact> datasource, string filePath)
        {
            return Task.Run(() =>
            {
                string binPath = System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "bin");
                var assembly = Assembly.Load(System.IO.File.ReadAllBytes(binPath + "\\NowManagementStudio.dll"));

                using (Stream stream = assembly.GetManifestResourceStream(Report))
                {
                    var viewer = new ReportViewer();
                    viewer.LocalReport.EnableExternalImages = true;
                    viewer.LocalReport.LoadReportDefinition(stream);

                    Warning[] warnings;
                    string[] streamids;
                    string mimeType;
                    string encoding;
                    string filenameExtension;

                    viewer.LocalReport.DataSources.Add(new ReportDataSource("DataSet1", datasource));

                    viewer.LocalReport.Refresh();

                    byte[] bytes = viewer.LocalReport.Render(
                        "PDF", null, out mimeType, out encoding, out filenameExtension,
                        out streamids, out warnings);

                    using (FileStream fs = new FileStream(filePath, FileMode.Create))
                    {
                        fs.Write(bytes, 0, bytes.Length);
                    }
                }
            });
        }
开发者ID:wiechars,项目名称:NowManagementStudio,代码行数:34,代码来源:ReportGenerator.cs

示例5: ExportReport

        private static string ExportReport(ReportViewer reportViewer1, List<string> agency, List<string> contractNumber, int i)
        {
            Warning[] warnings;
            string[] streamids;
            string mimeType;
            string encoding;
            string extension;

            byte[] bytes;
            bytes = reportViewer1.ServerReport.Render("Excel", null, out mimeType, out encoding, out extension, out streamids, out warnings);

            //write to temp file
            DateTime todaysDate = DateTime.Today;
            string month = todaysDate.Month.ToString();
            string day = todaysDate.Day.ToString();
            string year = todaysDate.Year.ToString();
            string runDate = month + "_" + day + "_" + year;

            string reportName = agency[i]+"_"+contractNumber[i]+"_"+runDate+".xls";

            //
            //N:\\PERFORMANCE\\AGENCY REPORTS\\Agency submissions\\2016 Reports Received\\Test_QPR2015_AA\\
            string fileName = Path.Combine("G:\\Wendy\\DIRMonthly\\", reportName);

            using (FileStream fs = new FileStream(fileName, FileMode.Create))
            {
                fs.Write(bytes, 0, bytes.Length);
            }

            return fileName;
        }
开发者ID:angeles890,项目名称:localApps,代码行数:31,代码来源:Program.cs

示例6: ShowReport

        private void ShowReport(IObjectContainer container)
        {
            // #example: Run a report with db4o
            var dataToShow = from Person p in container
                             where p.FirstName.Contains("o")
                             select p;

            var reportViewer = new ReportViewer
            {
                ProcessingMode = ProcessingMode.Local
            };

            // Put the data into the datasource which you are using
            // in your report. Here it's named 'MainData'
            reportViewer.LocalReport.DataSources.Add(
                new ReportDataSource("MainData", dataToShow));
            reportViewer.Dock = DockStyle.Fill;

            // The report can be an embedded resource
            reportViewer.LocalReport.ReportEmbeddedResource = "Db4oDoc.Code.Reporting.ExampleReport.rdlc";
            // or can be a file
            // reportViewer.LocalReport.ReportPath = "path/to/your/report"; 

            // After that you can use the report viewer in your app
            this.Controls.Add(reportViewer);
            reportViewer.RefreshReport();
            // #end example
        }
开发者ID:Galigator,项目名称:db4o,代码行数:28,代码来源:ReportForm.cs

示例7: btnSalvar_Click

        private void btnSalvar_Click(object sender, EventArgs e)
        {
            //local
            ReportViewer report = new ReportViewer();
            report.ProcessingMode = ProcessingMode.Local;

            report.LocalReport.ReportEmbeddedResource = "MariosPet.Report1.rdlc";

            //criar listas
            List<ReportParameter> lista = new List<ReportParameter>();

            lista.Add(new ReportParameter("NomeVeterinario", txtNomeVeterinario.Text));
            lista.Add(new ReportParameter("Prescricao", txtPrescricao.Text));

            report.LocalReport.SetParameters(lista);

            Warning[] warnings;
            string[] streamids;
            string mimeType;
            string encoding;
            string extrension;

            byte[] bytePdf = report.LocalReport.Render("PDF", null, out mimeType, out encoding ,out extrension, out streamids, out warnings);

            //criar pdf
            FileStream file = null;
            string nomeArquivo = Path.GetTempPath() + "Receiturario" + DateTime.Now.ToString("dd_MM_yyyy-HH_mm_ss") + ".pdf";

            //abrir pdf
            file = new FileStream(nomeArquivo, FileMode.Create);
            file.Write(bytePdf, 0, bytePdf.Length);
            file.Close();
            Process.Start(nomeArquivo);
        }
开发者ID:MariosPets,项目名称:Pet,代码行数:34,代码来源:FrmReceituario.cs

示例8: anteprimaStampaBilancioLoad

        private void anteprimaStampaBilancioLoad(object sender, EventArgs e)
        {
            // Set Processing Mode
            _reportViewer = new ReportViewer {ProcessingMode = ProcessingMode.Local};
            
            // Set RDL file
            _reportViewer.LocalReport.ReportEmbeddedResource = "Gipasoft.Stabili.UI.StatoPatrimoniale.Reports.DettaglioPartitario.rdlc";

            // Supply a DataTable corresponding to each report dataset
            _reportViewer.LocalReport.DataSources.Add(new ReportDataSource("MovimentoContabileBilancioDTO", _partitario));

            // Add the reportviewer to the form
            Controls.Add(_reportViewer);
            _reportViewer.Dock = DockStyle.Fill;

            _reportViewer.LocalReport.EnableExternalImages = true;

            var parameterCondominio1 = new ReportParameter("condominio1", _reportParameters.DescrizioneCondominio[0]);
            var parameterCondominio2 = new ReportParameter("condominio2", _reportParameters.DescrizioneCondominio[1]);
            var parameterCondominio3 = new ReportParameter("condominio3", _reportParameters.DescrizioneCondominio[2]);
            var parameterCondominio4 = new ReportParameter("condominio4", _reportParameters.DescrizioneCondominio[3]);
            var parameterCodiceCondominio = new ReportParameter("codiceCondominio", _reportParameters.CodiceCondominio);
            var parameterEsercizio = new ReportParameter("esercizio", _reportParameters.DescrizioneEsercizio);
            var parameterAzienda = new ReportParameter("azienda", _reportParameters.DescrizioneAzienda);
            var parameterGriglia = new ReportParameter("griglia", _reportParameters.VisualizzaGriglia.ToString());
            var parameterNote = new ReportParameter("note", _reportParameters.Note);

            var parameterIntestazioneStudio = new ReportParameter("intestazioneStudio", _reportParameters.IntestazioneStudio);
            var parameterViaStudio = new ReportParameter("viaStudio", _reportParameters.ViaStudio);
            var parameterCapStudio = new ReportParameter("capStudio", _reportParameters.CapStudio);
            var parameterLocalitaStudio = new ReportParameter("localitaStudio", _reportParameters.LocalitaStudio);
            var parameterLogo = new ReportParameter("logo", _documentService.SaveInLocalCache(new Gipasoft.Business.Interface.DocumentInfo() { Body = _aziendaService.GetLogo().LogoAzienda, FileName = "logo.jpg" }));

            string dataSituazione = "Fine esercizio";
            if (_reportParameters.DataSituazione != null)
                dataSituazione = _reportParameters.DataSituazione.Value.ToShortDateString();
            var parameterDataSituazione = new ReportParameter("dataSituazione", dataSituazione);

            _reportViewer.LocalReport.SetParameters(
                new [] 
                { 
                    parameterCondominio1, 
                    parameterCondominio2, 
                    parameterCondominio3, 
                    parameterCondominio4, 
                    parameterCodiceCondominio,
                    parameterEsercizio, 
                    parameterAzienda, 
                    parameterGriglia, 
                    parameterNote, 
                    parameterIntestazioneStudio,
                    parameterViaStudio,
                    parameterCapStudio,
                    parameterLocalitaStudio,
                    parameterLogo,
                    parameterDataSituazione
                });

            _reportViewer.RefreshReport();
        }
开发者ID:gipasoft,项目名称:Sfera,代码行数:60,代码来源:AnteprimaStampaPartitario.cs

示例9: WordUpReportContainer

		public WordUpReportContainer ()
			{
			InitializeComponent ();
			ReportViewer = new ReportViewer ();

			windowsFormsHost.Child = ReportViewer;
			}
开发者ID:heinzsack,项目名称:DEV,代码行数:7,代码来源:WordUpReportContainer.cs

示例10: CreateReport

		public static ReportViewer CreateReport()
		{
			var reportViewer = new ReportViewer();
			AddReport(reportViewer);

			return reportViewer;
		}
开发者ID:GeertvanHorrik,项目名称:ApprovalTests.Net,代码行数:7,代码来源:ReportHelper.cs

示例11: Print

        public FileResult Print()
        {
            var bandId = Convert.ToInt32(Session["BandId"]);
            var rv = new ReportViewer { ProcessingMode = ProcessingMode.Local };
            var ds = new GetAllSongsTableAdapter();
            var connection = new SqlConnection(ConfigurationManager.ConnectionStrings["ReportConnectionString"].ConnectionString);
            ds.Connection = connection;

            string reportPath = "~/Reports/Songs.rdlc";

            rv.LocalReport.ReportPath = Server.MapPath(reportPath);
            rv.ProcessingMode = ProcessingMode.Local;

            ReportDataSource rds = new ReportDataSource("Songs", (object)ds.GetData(bandId));
            rv.LocalReport.DataSources.Add(rds);
            rv.LocalReport.Refresh();

            string mimeType = string.Empty;
            string encoding = string.Empty;
            string filenameExtension = string.Empty;
            string[] streamids;
            Warning[] warnings;
            var streamBytes = rv.LocalReport.Render("PDF", null, out mimeType, out encoding, out filenameExtension, out streamids, out warnings);

            var bandName = _bandRepository.Get(bandId).Name;
            var filename = bandName + ".pdf";

            return File(streamBytes, mimeType, filename);
        }
开发者ID:jyuma,项目名称:SetGenerator,代码行数:29,代码来源:SongsController.cs

示例12: Sample

        public Sample()
        {
            //snippet
            //MySqlDataReader reader = cmd.ExecuteReader();

            // add to collection
            List<MyReportClass> myReportClassCollection = new List<MyReportClass>();

            //while (reader.Read())
            //{
            // populate entity
            var myReportClass = new MyReportClass();
            // set properties, skipping DBNull checking for quickness
            myReportClass.ID = 1;//(int)reader["ID"];
            myReportClass.Name = "Test";//(string) reader["Name"];

            myReportClassCollection.Add(myReportClass);
            //}

            ReportViewer viewer = new ReportViewer();
            viewer.ProcessingMode = ProcessingMode.Local;
            viewer.LocalReport.ReportPath = Path.Combine(Environment.CurrentDirectory, "Report\\crBalanceReport.rdlc");
            viewer.LocalReport.DataSources.Add(new ReportDataSource("myDataSource", myReportClassCollection));
            //viewer.LocalReport.Render("PDF", "", out mimeType, out encoding, out extension, out streamIds, out warnings);
        }
开发者ID:niyomja,项目名称:laksi-tractor,代码行数:25,代码来源:Sample.cs

示例13: generateInvoicePDF

        public static string generateInvoicePDF(int invoiceID)
        {
            Microsoft.Reporting.WebForms.ReportViewer reportViewer = new ReportViewer();
            string reportPath = null;

            string appPath = ConfigurationManager.AppSettings["appPath"].ToString();

            invoiceReport = CRM.Repository.InvoiceManager.GetInvoiceForReport(invoiceID);

            if (invoiceReport != null) {
                reportViewer.Reset();

                reportViewer.LocalReport.DataSources.Clear();

                reportViewer.LocalReport.EnableExternalImages = true;

                ReportDataSource reportDataSource = new ReportDataSource();

                reportDataSource.Name = "DataSet1";

                reportDataSource.Value = invoiceReport;

                reportViewer.LocalReport.DataSources.Add(reportDataSource);

                reportViewer.LocalReport.ReportPath = HttpContext.Current.Server.MapPath("~/Content/Invoice.rdlc");

                reportViewer.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(invoiceReportSubReport);

                reportPath = string.Format("{0}/Temp/Invoice_{1}.pdf", appPath, invoiceID);

                Core.ReportHelper.savePDFFromLocalReport(reportViewer.LocalReport, reportPath);
            }

            return reportPath;
        }
开发者ID:Antoniotoress1992,项目名称:asp,代码行数:35,代码来源:ReportHelper.cs

示例14: printReceipt

        private void printReceipt(object sender, EventArgs e)
        {
            ReportDataSource source = new ReportDataSource();
            ReportViewer reportViewer = new ReportViewer();

            source.Name = "DataSet1";
            source.Value = null;

            ReportParameter p1 = new ReportParameter("test1", "ASV");
             //   reportViewer.Reset();
               // reportViewer.LocalReport.DataSources.Clear();
              reportViewer.LocalReport.ReportPath = "../../Reports/ReportReceipts.rdlc";
              ReportParameter rp = new ReportParameter();
              rp.Name = "id";
              rp.Values.Add(objectReceipt.Id);
              ReportParameter rp1 = new ReportParameter("contractid", objectReceipt.Contractid, true);
              ReportParameter rp2 = new ReportParameter("dateestablish", this.objectReceipt.Dateestablish, true);
              ReportParameter rp3 = new ReportParameter("billid", this.objectReceipt.Billid, true);
              ReportParameter rp4 = new ReportParameter("customername", this.objectReceipt.Customername, true);
              ReportParameter rp5 = new ReportParameter("total", this.objectReceipt.Total.ToString(), true);
              ReportParameter rp6 = new ReportParameter("reason", this.objectReceipt.Reason, true);
              ReportParameter rp7 = new ReportParameter("note", this.objectReceipt.Contents, true);
              ReportParameter[] parameter = new ReportParameter[] { rp, rp2, rp1, rp3, rp4, rp5, rp6, rp7 };
             // reportViewer.LocalReport.SetParameters(p);
              // reportViewer.LocalReport.DataSources.Add(source);

              ReportReceipts form = new ReportReceipts(parameter);
            form.Show();
        }
开发者ID:nguyenvanuyn96,项目名称:MotelManagermentFinal,代码行数:29,代码来源:ReceiptEdit.cs

示例15: GetLocalReport

        private byte[] GetLocalReport(ReportDataSource rs, string reportName, Dictionary<string, string> parameters)
        {
            var rview = new ReportViewer();

            rview.LocalReport.ReportPath = string.Format("{0}{1}.rdlc", HostingEnvironment.MapPath("~/Reports/"), reportName);

            rview.ProcessingMode = ProcessingMode.Local;
            rview.LocalReport.DataSources.Clear();
            rview.LocalReport.DataSources.Add(rs);

            var paramList = new List<ReportParameter>();

            if (parameters.Count > 0)
            {
                foreach (KeyValuePair<string, string> kvp in parameters)
                {
                    paramList.Add(new ReportParameter(kvp.Key, kvp.Value));
                }
            }

            rview.LocalReport.SetParameters(paramList);

            string mimeType, encoding, extension;
            string[] streamids;
            Warning[] warnings;

            string format = "Excel";

            byte[] bytes = rview.LocalReport.Render(format, null, out mimeType, out encoding, out extension, out streamids, out warnings);

            return bytes;
        }
开发者ID:ucdavis,项目名称:Commencement,代码行数:32,代码来源:TicketController.cs


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