原文:RDLC Reporting in Visual Studio 2017

Visual Studio 2017 中可以使用 RDLC Reporting 插件来设计报表,SAP Crystal Report(水晶报表)的用法与之类似。

步骤一、在 VS 中打开 “工具” 菜单下的 “扩展与更新” 选项,搜索 RDLC Reporting,并安装:

  1. Microsoft Rdlc Report Designer for Visual Studio

    • Rdlc Designer and projects for ASP.Net and Windows Forms for Reporting Services Report Viewer Control
  2. Microsoft Reporting Services Projects
    • The Microsoft RDL report designer, projects and wizards for creating professional reports.

安装成功后,新建 WinForm 项目,并添加新项,就可以看到 “报表” 选项了。

步骤二、添加相关的 NuGet 包:Microsoft.ReportingServices.ReportViewerControl.Winforms

步骤三、为项目添加新项,选择 “报表” 并命名为 Report1.rdlc,然后打开 Report1.rdlc 并添加数据集。

步骤四、打开一个窗体,并在工具箱里的 Microsoft SQL Server 选项下选择 ReportViewer 控件,添加到 Form2 中。并设置其报表模板。

步骤五、在窗体的加载事件中添加具体的数据绑定逻辑

private void Form2_Load(object sender, EventArgs e)
{
reportViewer1.LocalReport.ReportEmbeddedResource = "WindowsFormsApp1.Report1.rdlc"; // 包含命名空间和报表文件名称 DataTable studentDt = new DataTable("DAS_Staff"); studentDt.Columns.Add("StaffID");
studentDt.Columns.Add("StaffFirstName");
studentDt.Columns.Add("StaffLastName"); studentDt.Rows.Add("", "Jack", "tt");
studentDt.Rows.Add("", "Lucy", "tt");
studentDt.Rows.Add("", "Jason", "tt");
studentDt.Rows.Add("", "Lili", "tt"); reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSet1", studentDt)); //注:这里数据源名称要与上面再报表模板中定义的数据源名称一致。 reportViewer1.RefreshReport(); this.reportViewer1.RefreshReport();
}

最后,运行程序显示效果如下:

参考资料:

http://shashangka.com/2017/05/17/enable-rdlc-reporting-in-visual-studio-2017
https://www.cnblogs.com/dreamos/p/7599253.html

RDLC Reporting in Visual Studio 2017的更多相关文章

  1. Visual Studio 2017十五项新功能体验

    Visual Studio 2017正式已经于2017.3.7号正式发布,选在这一天发布也是为了纪念Visual Studio 二十周年.MVP 2017技术峰会将于这个周末(3.17)在北京举办,由 ...

  2. 深入研究Visual studio 2017 RC新特性

    在[Xamarin+Prism开发详解三:Visual studio 2017 RC初体验]中分享了Visual studio 2017RC的大致情况,同时也发现大家对新的Visual Studio很 ...

  3. Xamarin+Prism开发详解三:Visual studio 2017 RC初体验

    Visual studio 2017 RC出来一段时间了,最近有时间就想安装试试,随带分享一下安装使用体验. 1,卸载visual studio 2015 虽然可以同时安装visual studio ...

  4. Microsoft Visual Studio 2017 for Mac Preview 下载+安装+案例Demo

    目录: 0. 前言 1. 在线安装器 2. 安装VS 3. HelloWorld 4. ASP.NET MVC 5. 软件下载 6. 结尾 0. 前言: 工作原因,上下班背着我的雷神,一个月瘦了10斤 ...

  5. Create an offline installation of Visual Studio 2017 RC

    Create an offline installation of Visual Studio 2017 RC ‎2016‎年‎12‎月‎7‎日                             ...

  6. Visual Studio 2017 RC 初探安装

    上次看到博客介绍 Visual Studio 2017 RC,看到其中一个改进是启动很快,这是一大进步,也是低配电脑的程序员的期望.不过还没体验,是驴是骡子拉出来看看,这不就开始下载. 1.打开官网: ...

  7. .NET十五周年生日快乐 (3月7日发布Visual Studio 2017正式版?)

    今天 是.NET 对世界首次亮相15 周年.2002 年 2 月 13 日,第一版本的.NET 发布作为 Visual Studio.NET 的一部分.它仿佛就在昨天为微软建设成"下一代 W ...

  8. Visual Studio 2017 离线安装方式

    Visual Studio, 特别是Visual Studio 2017 通常是一个在线安装程序,如果你在安装过程中失去连接,你可以遇到问题.但是,由于法律原因,微软没有提供完整的可下载的ISO镜像. ...

  9. 最强 IDE Visual Studio 2017 正式版发布

    Visual Studio 2017 正式版发布,该版本不仅添加了实时单元测试.实时架构依赖关系验证等新特性,还对许多实用功能进行了改进,如代码导航.IntelliSense.重构.代码修复和调试等等 ...

随机推荐

  1. 巧用前端神器,fakerjs生成json文件

    安装 cnpm install faker json-serve --save-dev 在目录下创建一个模板文件 示例 makeJson.js var faker = require('faker') ...

  2. css最佳实践(reset.css)

    html, body, div, span, object, iframe,h1, h2, h3, h4, h5, h6, p, blockquote, pre,abbr, address, cite ...

  3. 跨平台移动开发phonegap/cordova 3.3全系列教程-app启动画面

    1.app启动画面设计 用photoshop设计启动画面,图片分辨率为720*1280 保存的文件名为splash.png 将splash.png复制到res\drawable,如图 PS:要先添加闪 ...

  4. 卸载VS2013 2015

    我有两个VS,特别讨厌,每当使用window程序删除时候,就出现 停止工作! 然后从知乎上发现了这个 https://github.com/Microsoft/VisualStudioUninstal ...

  5. sql server2016安装程序图

    今天终于有时间安装SQL Server2016正式版,下载那个安装包都用了一个星期 安装包可以从这里下载: http://www.itellyou.cn/ https://msdn.microsoft ...

  6. ajax请求成功后js刷新当前页,当前页是post查询结果(用post请求进行搜索筛选)的问题

    下面的一个ajax操作,原先操作成功会刷新当前页,保证用户看到的数据是最新的,一般情况不会出现问题.$.ajax({ url: url + "/addTeacherAuth", / ...

  7. linux命令 ——目录

    开始详细系统的学习linux常用命令,坚持每天一个命令,所以这个系列为每天一个linux命令.学习的主要参考资料为: 1.<鸟哥的linux私房菜> 2.http://codingstan ...

  8. JavaScript操作Array对象常用的方法

     转换方法 因为JavaScript内部机制(继承),所有的对象都具有toLocalString() .toString().valueOf()方法,Array也不例外so:var colors = ...

  9. TypeScript task

    Ctrl+Shift+B 生成 js 文件.

  10. theano支持的数组、向量、矩阵表达式

    1)theano主要支持符号矩阵表达式 (2)theano与numpy中都有broadcasting:numpy中是动态的,而theano需要在这之前就知道是哪维需要被广播.针对不同类型的数据给出如下 ...