WinForm客户端软件开发时,使用rdlc做报表,并且使用ReportViewer呈现报表时,开发者的机器运行正常。但是部署到第三方机器上运行时报错。 copy C:\Windows\assembly\gac_msil\Microsoft.ReportViewer.Common\11.0.0.0__89845dcd8080cc91\Microsoft.ReportViewer.Common.dll D:\ReportViewer copy C:\Windows\assembly\gac_msil\Microsoft.ReportViewer.WinForms\11.0.0.0__89845dcd8080cc91 \Microsoft.ReportViewer.WinForms.DLL D:\ReportViewer copy C:\Windows\assembly\gac_msil\Microsoft.ReportViewer.ProcessingObjectModel \11.0.0.0__89845dcd8080cc91\Microsoft.ReportViewer.ProcessingObjectModel.DLL D:\ReportViewer copy C:
\GAC_MSIL\Microsoft.ReportViewer.ProcessingObjectModel\11.0.0.0__89845dcd8080cc91\Microsoft.ReportViewer.ProcessingObjectModel.dll Microsoft.ReportViewer.WebDesign.dll C:\ copy C:\WINDOWS\assembly\GAC_MSIL\Microsoft.ReportViewer.WebDesign.resources \assembly\GAC_MSIL\Microsoft.ReportViewer.WebForms\11.0.0.0__89845dcd8080cc91\Microsoft.ReportViewer.WebForms.dll \Microsoft.ReportViewer.WebForms.resources.dll C:\ copy C:\WINDOWS\assembly\GAC_MSIL\Microsoft.ReportViewer.WinForms \Microsoft.ReportViewer.WinForms.resources\11.0.0.0_zh-CHS_89845dcd8080cc91\Microsoft.ReportViewer.WinForms.resources.dll
在Form1里新建一个ReportViewer1. \rptDEPT.rdlc"; this.reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSetDEPT ",GetDeptData())); this.reportViewer1.RefreshReport(); } private DataTable \rptDEPT.rdlc"; 24 this.reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSetDEPT += new SubreportProcessingEventHandler(LocalReport_SubreportProcessing); 28 29 this.reportViewer1
DataSet ds = GetDataSet(); ReportDataSource rds = new ReportDataSource("Orders", ds.Tables[0]); ReportViewer1 .LocalReport.DataSources.Clear(); ReportViewer1.LocalReport.DataSources.Add(rds); ReportViewer1 sqlforum/2011/04/27/walkthrough-assign-dataset-dynamically-created-in-code-to-your-local-report-with-reportviewer DataTable1"; this.DataTable1BindingSource.DataSource = ds; this.reportViewer1
PrintUtils { public static string PrintPaper(ContractTicket ticket, ContractOrder order, ReportViewer reportViewer1) { bool flag = false; ReportParameter[] rps = new ReportParameter .LocalReport.SetParameters(rps); reportViewer1.RefreshReport(); reportViewer1 reportViewer1 = new Microsoft.Reporting.WinForms.ReportViewer(); reportViewer1.LocalReport.ReportEmbeddedResource "FB.Client.Report1.rdlc"; string message = PrintUtils.PrintPaper(ticket, order, reportViewer1
添加引用,因为项目的.Net框架版本是4.0,因此ReportViewer的版本是9.0. 解决方法是,在工具箱中添加.Net 4.0的11.0版本的ReportViewer,并使用该控件来显示报表。 此后新建页面,拖入9.0版本的ReportViewer,即可以查看报表。 原因在于,ReportViewer版本的属性,不是在某个控件上指定的,而是在所在的页面中指定的。因此,不能在一个页面中存在两个不同版本的ReportViewer。 \11.0.0.0__89845dcd8080cc91\Microsoft.ReportViewer.WebForms.DLL' and 'c:\Windows\assembly\GAC_MSIL\Microsoft.ReportViewer.WebForms 因为ReportViewer引用的报表以及数据源等,都存在版本兼容的问题,都需要修改。
IsPostBack) { this.ReportViewer1.LocalReport.ReportPath = "rptDEPT.rdlc" ; this.ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DS_DEPT", GetDeptData IsPostBack) { this.ReportViewer1.LocalReport.ReportPath = "rptDEPT.rdlc" ; this.ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource += new SubreportProcessingEventHandler(LocalReport_SubreportProcessing); this.ReportViewer1
= 1)
{
this.ReportViewer1.CurrentPage--;
}
}
///
copy C:\Windows\assembly\gac_msil\Microsoft.ReportViewer.Common\11.0.0.0__89845dcd8080cc91\Microsoft.ReportViewer.Common.dll D:\ReportViewer copy C:\Windows\assembly\gac_msil\Microsoft.ReportViewer.WinForms\11.0.0.0__89845dcd8080cc91 \Microsoft.ReportViewer.WinForms.DLL D:\ReportViewer copy C:\Windows\assembly\gac_msil\Microsoft.ReportViewer.ProcessingObjectModel \11.0.0.0__89845dcd8080cc91\Microsoft.ReportViewer.ProcessingObjectModel.DLL D:\ReportViewer copy C:\ 复制到D盘ReportViewer目录后,将其复制到项目的bin\Debug目录,再次运行程序,一切正常。
= this.ReportViewer; reportViewer.EnableHybrid = this.ShowHybrid; if (reportViewer ! (reportViewer.Parent.Controls.IndexOf(reportViewer), child); BrowserNavigationCorrector child2 = reportViewer.CreateNavigationCorrector(); reportViewer.Parent.Controls.AddAt(reportViewer.Parent.Controls.IndexOf (reportViewer), child2); 例如,可以通过在本地 SharePoint服务器中调用/ReportServer/pages/ReportViewer.aspx页面来触发此功能. 0x02 :漏洞验证(POC) 可以将以下HTTP请求发送到服务器以利用该应用程序: POST /ReportServer/pages/ReportViewer.aspx HTTP/1.1 Host: target
而且纸张大小为A5的大小(注意:PageSize的设置,在界面上看不出效果,但是关闭对话框后,返回值的PageSize里会起作用) 三、RDLC报表用代码指定打印机、纸张大小、打印份数 rdlc报表的预览控制ReportViewer // Returns the page settings that are used to print the current report in the // ReportViewer object that contains the page settings // that are used to print the current report in the ReportViewer control or // display it in print layout mode, or null if the ReportViewer control has pdfFactory Pro" }; 要指定RDLC打印时,采用特定的纸张大小,可以参考下面的代码: var pageSettings = this.reportViewer1
保存,报表完成, 下面搞窗体,拉一个ReportViewer控件到窗体上, ? 如果工具箱内找不到的话就自己添加进来一个,如下 ? dr[1] = "b"; 9 dt.Rows.Add(dr); 10 } 11 reportViewer1 Application.StartupPath + "\\Report1.rdlc"; 12 //指定数据集,数据集名称后为表,不是DataSet类型的数据集 13 this.reportViewer1 ("message", dt)); //在vs2005中没有找到重命名为messge的方法,这里这样写 // this.reportViewer1 Microsoft.Reporting.WinForms.ReportDataSource("DataSet1_mytable",dt)); 15 //显示报表 16 this.reportViewer1
本着程序员何必难为程序员的原则,折腾出解决方案如下: 事实上,只需要找到相关的dll就行,那么你需要找到以下dll: Microsoft.ReportViewer.WebForms.dll(VS安装目录下的 ReportViewer目录,如D:\Program Files (x86)\Microsoft Visual Studio 11.0\ReportViewer,你可以从项目引用的这个dll的属性中找到路径 ) zh-CHS目录(简体中文语言包,如果你需要别的语言,那么复制其他的,VS安装目录下的ReportViewer目录,如D:\Program Files (x86)\Microsoft Visual Studio 11.0\ReportViewer) Microsoft.ReportViewer.Common.dll(GAC,注意版本号为11.0.0.0) Microsoft.ReportViewer.ProcessingObjectModel.DLL
HumanResources.Employee AS e ON s.SalesPersonID = e.EmployeeID 这里的@title就是一个参数,需要在运行的时候提供 在web中显示报表可以通过MS提供的ReportViewer 控件, <rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana" Font-Size="8pt" 1094px"> <ServerReport ReportPath="/Dynamic Query Tutorial/SmallSchoolBase7" /> </rsweb:ReportViewer ReportParameter> list = new List<ReportParameter>(); list.Add(parameter); this.ReportViewer1 .ServerReport.SetParameters(list); this.ReportViewer1.ShowParameterPrompts = false;
起因:客户的程序使用了Microsoft.ReportViewer,程序中需要把这个安装到客户端,需要在目录下放置以下三个dll: Microsoft.ReportViewer.Common Microsoft.ReportViewer.WinForms Microsoft.ReportViewer.ProcessingObjectModel 过程:在我的电脑中寻找上面三个dll。 前两个在目录“C:\Program Files\Microsoft Visual Studio 9.0\ReportViewer”下找到,但是第三个却没有。
三、将报表嵌入到网页中 创建一个aspx页,拖放一个ReportViewer到页面上,然后再拖放一个ScriptManager到页面上,最终的代码如下: <%@ Page Language="C#" AutoEventWireup ="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <%@ Register Assembly="Microsoft.<em>ReportViewer</em>.WebForms "> <title></title> </head> <body> <form id="form1" runat="server">
其实能够达到这样的效果需要做两方面的工作:添加报表控件ReportViewer和添加编辑RDLC文件。 个人感觉RDLC文件的作用是绑定数据库中需要的数据,ReportViewer则是引用RDLC文件来显示RDLC文件从数据库中绑定的数据。 1、添加报表控件ReportViewer: 添加报表控件很简单:工具箱—报表—ReportViewer控件。 2、添加和编辑编辑RDLC文件: 添加RDLC文件,有两种方法:1、鼠标左击一下刚刚添加的ReportViewer,会发现控件右上角会出现一个黑色的小三角,点击那个小三角→设计新报表: ? 最后,重新单击第一步添加的ReportViewer空间,点击右上角的小三角,在“选择报表”后选择您刚制作的报表就大功告成了。
data.Where(WhereCondition(item)); } return data.ToList(); } } 数据库查询函数已经完成,接下来就是要用ReportViewer 来展现查询出来的结果绑定到报表中,具体代码如下: private void BindData(string q) { var datas = DbOperation.SearchData(q); this.ReportViewer1 .LocalReport.DataSources.Clear(); this.ReportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource ( "DataSet1", datas)); this.ReportViewer1
前段时间,做了RDLC报表,主要是三块功能: 1、从DataGrid提取(包括最新的增删改)数据,自动生成对应的RDLC报表文件(以流的形式驻存在内存中),用ReportViewer类来展示、打印、排版 = null) { reportViewer.Reset(); reportViewer.LocalReport.DataSources.Clear (); reportViewer.Clear(); if (! reportViewer, string rdlcModelFileName, string headline) 11 { 12 if (! (DisplayMode.PrintLayout); 3 reportViewer.ZoomMode = ZoomMode.Percent; 4 reportViewer.ZoomPercent
private void btnSearch_Click(object sender, EventArgs e) 2: { 3: //加载报表 4: 5: if (this.reportViewer.SourceRdl 商品入库查询报表.rdl"); 11: textReader = new System.IO.StreamReader(fileName); 12: this.reportViewer.SourceRdl table.GetProductInList(this.dtpStartTime.Value,this.dtpEndTime.Value, this.tbSearch.Text); 24: this.reportViewer.DataObject