vs2017还支持reportviewer控件吗

如题所述

VS2017 支持ReportViewer .首先你要先安装 RDLC Report .在https://marketplace.visualstudio.com/items?itemName=SqlReportingServices.MicrosoftRdlcReportDesignerforVisualStudio-18001 这个地址下载。下载安装后,打开VS2017,然后点工具菜单,选择NuGet包管理器中的manager NuGet Packages for solution ,在浏览界面上搜索 reportviewer ,就会找到很多的RDLC版本。如果你想要使用微软的,那就请你搜索 reportviewercontrol ,出来的两个都微软出品的一个是winform一个是web的。然后就下载安装。安装完毕就可以在VS2017中使用 ReportViewer了。如果添加不了控件到工具栏,请直接手动在页面里添加。先在页面注册ReportViewer控件 <%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=14.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>
然后添加 <asp:ScriptManager runat="server"></asp:ScriptManager>
<rsweb:ReportViewer ID="ReportViewer1" runat="server" Width="1400px" Height="800px">
<LocalReport ReportPath="Report.rdlc">
</LocalReport>
</rsweb:ReportViewer>
这样就可以了。
温馨提示:答案为网友推荐,仅供参考
第1个回答  2017-05-24
1.先创建一个本地的数据库,右键单击你的项目-->选择【Add】--->New Item--->Local database.创建数据库后,添加一个数据表T_student,添加一些数据。
2.右键---->【Add】--->New Item--->Dataset(命名为information.xsd),把刚才创建的表T_student直接拖到information.xsd的设计界面上。
3.右键---->【Add】---->New Item---> Report(命名为report.rdlc),在report.rdlc的界面上右键---->【insert】---->【table】,此时会出现一个配置窗口,第一个【Name】填写你添加的dataset的名称(information),Data source选项选择information.
4.然后到winform界面。添加ReportViewer控件
5.在Form.cs中编写代码:
private void button2_Click(object sender, EventArgs e)
{
information ds1 = new information();
informationTableAdapters.table11TableAdapter ap = new informationTableAdapters.table11TableAdapter();
ap.Fill(ds1.table11);
DataTable dt1 = new DataTable();
dt1 = ds1.table11;
this.reportViewer1.Reset();
this.reportViewer1.LocalReport.DataSources.Clear();
this.reportViewer1.LocalReport.ReportPath = @"E:\test code\水晶报表\水晶报表\report1.rdlc";
ReportDataSource rds = new ReportDataSource("information", dt1); //ReportDataSource数据源的第一个参数必须与你添加的dataset的名字相同
this.reportViewer1.LocalReport.DataSources.Add(rds); //添加数据源
this.reportViewer1.ZoomMode = ZoomMode.Percent;
this.reportViewer1.RefreshReport();
}本回答被提问者采纳
相似回答