【发布时间】:2011-11-30 00:36:23
【问题描述】:
好的,我在使用 RDLC 时遇到了很多问题,所以回到 RDL 报告。现在,我知道我需要一个报告服务器来运行报告,然后在前端我可以使用报告查看器并选择报告的路径。我正在使用我的本地计算机,所以至少要让它在本地工作。我不明白如何在本地安装报告服务器。我在网上找到了几篇 MSDN 文章,但它们过于复杂。是否有关于如何在网页中使用 RDL 报告的简单教程?
【问题讨论】:
标签: asp.net reporting-services
好的,我在使用 RDLC 时遇到了很多问题,所以回到 RDL 报告。现在,我知道我需要一个报告服务器来运行报告,然后在前端我可以使用报告查看器并选择报告的路径。我正在使用我的本地计算机,所以至少要让它在本地工作。我不明白如何在本地安装报告服务器。我在网上找到了几篇 MSDN 文章,但它们过于复杂。是否有关于如何在网页中使用 RDL 报告的简单教程?
【问题讨论】:
标签: asp.net reporting-services
SQL Server Reporting Services (SSRS) 作为 Microsoft SQL Server 的一部分安装。您需要使用 SQL Server 安装介质来安装 SSRS。您可以只安装 SSRS 而不安装其他 SQL Server 组件,但您需要有一个 SQL Server 来存储 SSRS 保存其数据的数据库。
我对低端选项没有太多经验,但 SSRS 可用于“SQL Server Express with Advanced Services”
【讨论】:
我想你对 asp.net 很熟悉。创建一个新的 asp.net 应用程序或网站。 添加Microsoft.Reporting.WebForms的引用(右键-->添加引用)
然后将其添加到您的 Page 指令中
<%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>
那么你应该可以使用reportviewer控件了
<rsweb:ReportViewer ID="rptOne" runat="server" AsyncRendering="true" ProcessingMode="Remote"
ShowPrintButton="false" ShowPageNavigationControls="true" ShowParameterPrompts="false"
ShowBackButton="true" ShowExportControls="true" Height="1000px" Width="1000px"
SizeToReportContent="false">
</rsweb:ReportViewer>
(显然,你不需要设置我所做的所有属性。)
然后您可以在后面的代码中设置您的网址
Me.rptOne.ServerReport.ReportServerUrl = New System.Uri(sUrl)
Me.rptOne.ServerReport.ReportPath = sPath
【讨论】:
报告有用的文档不多,但比较困难 SQL Server Reporting Services (SSRS) 使一个类在此代码中传递整个报表查看器 sn-p rpt = 在堆上传递的报表查看器: rpt.LocalReport.DataSources.Clear();
Microsoft.Reporting.WebForms.ReportDataSource rptdTitle = new Microsoft.Reporting.WebForms.ReportDataSource();
rptdTitle.Name = "DataSet1";
rptdTitle.Value = dt2;
rpt.LocalReport.DataSources.Add(rptdTitle);
Microsoft.Reporting.WebForms.ReportDataSource rptdTop = new Microsoft.Reporting.WebForms.ReportDataSource();
rptdTop.Name = "DataSet2";
rptdTop.Value = dt1;
rpt.LocalReport.DataSources.Add(rptdTop);
Microsoft.Reporting.WebForms.ReportDataSource rptDate = new Microsoft.Reporting.WebForms.ReportDataSource();
rptDate.Name = "DataSet3";
rptDate.Value = dsTableDate;
rpt.LocalReport.DataSources.Add(rptDate);
Microsoft.Reporting.WebForms.ReportDataSource rptTable = new Microsoft.Reporting.WebForms.ReportDataSource();
rptTable.Name = "DataSet4";
rptTable.Value = dtReport;
rpt.LocalReport.DataSources.Add(rptTable);
rpt.LocalReport.ReportPath = System.Web.HttpContext.Current.Server.MapPath(@"~\Reports\rptPeriodTotals.rdlc");
rpt.LocalReport.Refresh();
【讨论】: