visual studio 2017 RC 中缺少 Reportviewer 工具

Reportviewer tool missing in visual studio 2017 RC

我刚开始在名为 visual studio 2017 RC 的新版本 visual studio 中编写报告软件,但我发现 windows 表单和 WPF 应用程序模板都缺少核心报告查看工具.谁能告诉我为什么 reportviewer 工具从 visual studio 2017 中消失了?没有它真的很麻烦。在 new visual studio 中是否有任何替代方法可以使用此工具?

** 更新**:11/19/2019

Microsoft 已在其 Nuget 库中发布了新版本的控件 150.1400.0。我的简短测试表明它在表单设计器中再次工作,而 150.1357.0150.1358.0 没有。这包括能够调整和修改控件本身的 ReportViewer 任务。

** 更新**:2019 年 8 月 18 日

删除最新版本并回滚到 150.900.148.0 似乎适用于我使用 VS2017 和 VS2019 的多台计算机。

您可以在 Nuget 解决方案包管理器中回滚到 150.900.148。它的工作原理与以前的版本类似。使用下拉框select旧版本。

手动删除对 post 150.900 版本 ReportViewer 的引用并读取它们可能比修复它们更容易。

记得在更改工具箱条目后重新启动Visual Studio。

更新:2019 年 8 月 7 日

ReportViewer 控件的更新版本已经发布,可能恰逢 Visual Studio 2019 年。我正在使用 V150.1358.0。

按照此答案中的说明获取设计器工具箱中的控件。但是一旦放在表格上它就不会显示。控件作为非可视组件显示在窗体下方。

这是根据 Microsoft SQL BI 支持设计的。这是负责控制的组。

虽然您仍然无法直接与控件交互,但这些额外的步骤提供了一种解决方法,因此可以在窗体上调整控件的大小。虽然现在可见,但设计者将控件视为不存在。

我已根据 Microsoft SQL BI 支持的建议创建了反馈请求。请考虑对其进行投票以引起 Microsoft 的注意。

Microsoft Azure Feedback page - Restore Designtime features of the WinForms ReportViewer Control

其他步骤:

  • 将报表查看器添加到 WinForm 后
  • 向 WinForm 添加面板控件。
  • 在表单的 form.designer.cs 文件中,将 Reportviewer 控件添加到面板。

      // 
      // panel1
      // 
      this.panel1.Controls.Add(this.reportViewer1);
    
  • Return 表单的设计者,您应该在面板上看到 reportViewer

  • 在属性面板中 select 控件列表下拉列表中的 ReportViewer
  • 将 reportViewer 的 Dock 属性 设置为 Fill

现在您可以通过实际与面板交互来定位 reportViewer。

更新:微软于2017年4月18日发布了一个document描述如何在Visual Studio2017中配置和使用报告工具。

Visual Studio2017 工具箱中默认没有安装ReportViewer工具。为 Visual Studio 安装扩展 Microsoft Rdlc Report Designer,然后将其添加到工具箱会导致在表单下方出现一个非可视组件。

Microsoft 支持告诉我这是一个错误,但截至 2017 年 4 月 21 日,它是 "working as designed"。

每个需要 ReportViewer 的项目都需要遵循以下步骤。

  • 如果工具箱中有 ReportViewer,请将其删除。突出显示,右键单击并删除。
    • 您必须有一个打开表单的项目才能执行此操作。

2019 年 8 月 7 日编辑 - 看起来当前版本的 RDLC 报告设计器扩展不再有干扰。您需要它来实际编辑报告。

  • 如果您安装了 Microsoft Rdlc Report Designer for Visual Studio 扩展,请将其卸载。

  • 关闭您的解决方案并重新启动 Visual Studio。这是 很关键的一步,如果没有重启VS会报错 在解决方案之间切换。

  • 打开你的解决方案。
  • 打开 NuGet 包管理器控制台 (Tools/NuGet Package Manager/Package Manager Console)
  • 在 PM> 提示符下输入此命令,区分大小写。

    Install-Package Microsoft.ReportingServices.ReportViewerControl.WinForms

    您应该会看到描述软件包安装的文本。

现在我们可以暂时将ReportViewer工具添加到工具箱中了。

  • 右键单击工具箱并使用Choose Items...

  • 我们需要浏览到位于解决方案 Packages 文件夹中的正确 DLL,因此请点击浏览按钮。

  • 在我们的示例中,我们可以粘贴到包文件夹中,如包管理器控制台的文本所示。

    C:\Users\jdoe\Documents\Projects\_Test\ReportViewerTest\WindowsFormsApp1\packages

  • 然后双击名为 Microsoft.ReportingServices.ReportViewerControl.Winforms.140.340.80

    以后版本号可能会改变。

  • 然后双击 lib 并再次双击 net40

  • 最后,双击文件Microsoft.ReportViewer.WinForms.dll

    您应该会在对话框中看到 ReportViewer 已选中。向右滚动,您将看到与之关联的版本 14.0.0.0。

  • 单击确定。

ReportViewer 现在位于工具箱中。

  • 将工具拖动到所需的形式。

  • 完成后,从工具箱中删除 ReportViewer 工具。您不能将它用于其他项目。

  • 您可以保存项目,一切顺利。

记得每次需要使用 ReportViewer 打开项目时重新启动 Visual Studio,以便从正确的位置加载 DLL。如果您尝试在不重新启动的情况下打开带有 ReportViewer 表单的解决方案,您将看到错误指示“The variable 'reportViewer1' is either undeclared or was never assigned.”。

如果您将新项目添加到您需要创建项目的同一解决方案,保存解决方案,重新启动 Visual Studio 然后您应该能够将 ReportViewer 添加到表单。我第一次看到它不起作用并显示为非可视组件。

发生这种情况时,从表单中删除组件,从项目中删除 Microsoft.ReportViewer.* 引用,保存并重新启动通常都可以。

请注意,每次您启动不同的项目时,都会重复上面@Rich Shealer 描述的添加报告服务的过程。为了避免这种情况:

  1. 如果您可能需要设置另一台计算机(例如,在没有互联网的家中),请将您从市场上下载的安装程序保存在安全的地方,即:

    • Microsoft.DataTools.ReportingServices.vsix,以及
    • Microsoft.RdlcDesigner.vsix
  2. 从您创建的包含报告服务的应用程序的包或 bin 文件夹中获取以下库:

    • Microsoft.ReportViewer.Common.dll
    • Microsoft.ReportViewer.DataVisualization.dll
    • Microsoft.ReportViewer.Design.dll
    • Microsoft.ReportViewer.ProcessingObjectModel.dll
    • Microsoft.ReportViewer.WinForms.dll
  3. 安装上面 1 中的 2 个组件

  4. 将上面 2 中的 dll 添加为引用(项目>引用>添加...)
  5. (可选)将报告选项卡添加到工具栏
  6. 将项目添加到报告选项卡
  7. 浏览到 bin 文件夹或您有上述 dll 的位置并添加它们

你现在可以开始了! ReportViewer 图标将添加到您的工具栏,当您想要将新项目...(报告)添加到您的项目时,您现在还会发现 Report 和 ReportWizard 模板已添加到您的常用模板列表中

注意:使用 Nuget 包管理器设置时,报告和报告向导模板在报告下分组。然而,使用我上面描述的方法不会在已安装的模板中添加报告分组,但我认为这没有任何问题,因为它使您能够在没有互联网的情况下快速集成 rdlc,并且无需每次都从 Nuget 下载您已经拥有的内容!

更新:此答案适用于 Visual Sudio 2017 和 2019

对我来说,它通过以下三个步骤起作用:

  1. 正在更新 Visual Studio 到最新版本。
  2. 添加报告/报告向导Add/New项目 菜单:
    • 前往 Visual Studio 菜单 Tools/Extensions 和更新
    • 从左侧面板中选择在线
    • 为Visual Studio
    • 搜索Microsoft Rdlc Report Designer
    • 下载并安装它。
  3. 通过以下方式添加报表查看器控件:

    • 前往 NuGet 包管理器

    • 正在安装Microsoft.ReportingServices.ReportViewerControl.Winforms

    • 转到包含 Microsoft.ReportViewer.WinForms.dll 的文件夹:%USERPROFILE%\.nuget\packages\microsoft.reportingservices.reportviewercontrol.winforms0。 1000.523\lib\net40
    • Microsoft.ReportViewer.WinForms.dll 文件拖放到 Visual Studio 工具箱Window。

对于 WebForms 应用程序:

  1. 一样。
  2. 一样。
  3. 通过以下方式添加报表查看器控件:

    • 前往 NuGet 包管理器

    • 正在安装Microsoft.ReportingServices.ReportViewerControl.WebForms

    • 转到包含 Microsoft.ReportViewer.WebForms.dll 文件的文件夹:%USERPROFILE%\.nuget\packages\microsoft.reportingservices.reportviewercontrol.webforms0 .1000.523\lib\net40
    • Microsoft.ReportViewer.WebForms.dll 文件拖放到 Visual Studio 工具箱Window。

就这些了!

下载 Visual Studio 的 Microsoft Rdlc Report Designer 来自这个link。 https://marketplace.visualstudio.com/items?itemName=ProBITools.MicrosoftRdlcReportDesignerforVisualStudio-18001

微软详细解释步骤:

https://docs.microsoft.com/en-us/sql/reporting-services/application-integration/integrating-reporting-services-using-reportviewer-controls-get-started?view=sql-server-2017

下面的步骤总结了上面的文章。

将报表查看器控件添加到新的 Web 项目:

  1. 创建一个新的 ASP.NET 空网站或打开一个现有的 ASP.NET 项目。

  2. 通过 NuGet 包管理器控制台安装报表查看器控件 NuGet 包。 从 Visual Studio -> 工具 -> NuGet 包管理器 -> 包管理器控制台

    Install-Package Microsoft.ReportingServices.ReportViewerControl.WebForms
    
  3. 向项目添加一个新的 .aspx 页面并注册 Report Viewer 控件程序集以在该页面内使用。

    <%@ Register assembly="Microsoft.ReportViewer.WebForms, Version=15.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" namespace="Microsoft.Reporting.WebForms" tagprefix="rsweb" %>
    
  4. 将 ScriptManagerControl 添加到页面。

  5. 将报表查看器控件添加到页面。可以更新下面的代码片段以引用远程报表服务器上托管的报表。

     <rsweb:ReportViewer ID="ReportViewer1" runat="server" ProcessingMode="Remote">
     <ServerReport ReportPath="" ReportServerUrl="" /></rsweb:ReportViewer>
    

最终页面应如下所示。

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="Sample" %>

<%@ Register assembly="Microsoft.ReportViewer.WebForms, Version=15.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" namespace="Microsoft.Reporting.WebForms" tagprefix="rsweb" %>

<!DOCTYPE html>

<html xmlns="https://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="X-UA-Compatible" content="IE=edge" /> 
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager runat="server"></asp:ScriptManager>        
       <rsweb:ReportViewer ID="ReportViewer1" runat="server" ProcessingMode="Remote">
           <ServerReport ReportServerUrl="https://AContosoDepartment/ReportServer" ReportPath="/LatestSales" />
    </rsweb:ReportViewer>
    </form>
</body>

如果您像我一样尝试了其中的一些方法,但仍然停留在工具箱中有控件并可以在表单上绘制它但它从表单中消失并放在组件,然后简单地编辑设计器并在 InitializeComponent() 的适当区域添加以下内容以使其可见:

this.Controls.Add(this.reportViewer1);

or

[ContainerControl].Controls.Add(this.reportViewer1);

您还需要在添加控件后手动调整位置和大小。

这肯定不是一个很好的答案,但如果您遇到困难,只是需要暂时完成工作,直到您有更多时间解决问题,它应该会有所帮助。