帆软报表 js 调用sql_SQL Server中的报表–创建由先前创建的主报表调用的基于矩阵的子报表

帆软报表 js 调用sql

Introduction

介绍

As you will remember from our last “get together” we created an application that permitted us to report upon financial data based upon an unorthodox financial year. In fact, our fiscal year started in July and ended in June. We created a chart to display the data.

您可能会记得,从上次“ 聚会 ”开始,我们创建了一个应用程序,该应用程序使我们能够基于非正统的财务年度报告财务数据。 实际上,我们的会计年度从7月开始,到6月结束。 我们创建了一个图表来显示数据。

In today’s “get together” we are going to push our application a bit further and build in a subreport which will bring up the underlying data when the end user clicks upon the chart for any particular month. Thus should the user click on February 2015, then all of February’s data (for the selected funds) is shown in a matrix. If the user chooses March, then March’s data is shown.

在今天的“聚在一起”中,我们将进一步推动我们的应用程序并构建一个子报表,当最终用户单击任何特定月份的图表时,该子报表将显示基础数据。 因此,如果用户单击2015年2月,则矩阵中将显示2月份的所有数据(针对选定的资金)。 如果用户选择三月,则显示三月的数据。

Without further ado, let’s get started!

事不宜迟,让我们开始吧!

入门 ( Getting Started )

We begin by opening SQL Server Data Tools and opening the project that we created in the article entitled “Setting run dates on the fly”.

我们首先打开SQL Server数据工具,然后打开在标题为“即时设置运行日期”的文章中创建的项目。

Our report surface is brought into view. We note that at this stage in the game, that all we have is the chart.

我们的报告界面已成为现实。 我们注意到在游戏的这个阶段,我们所拥有的只是图表。

In SQL Server Management Studio, we open the stored procedure that we created for this chart.

在SQL Server Management Studio中,我们打开为此图表创建的存储过程。

We are now going to clone an additional stored procedure that will utilize an additional parameter and render the raw data behind the graph; the contents of which will be dependent upon which value of year month that is passed through via the main report. The code listing may be seen in Addenda 1.

现在,我们将克隆一个附加的存储过程,该过程将使用附加的参数并将原始数据呈现在图形后面。 其内容将取决于通过主报表传递的年份月份的值。 代码清单可以在附录1中看到。

The reader will note that we have added the parameter @YearMth to the stored procedure header (see above). Additionally, we have declared a variable @YearMth and set this variable to ‘201502’. This will be commented out once we are ready to create the new stored procedure.

读者会注意到,我们已将参数@YearMth添加到存储过程标头中(请参见上文)。 此外,我们已声明变量@YearMth并将此变量设置为'201502'。 一旦我们准备创建新的存储过程,这将被注释掉。

In the screen dump above, we are able to view the result set generated by the query.

在上面的屏幕转储中,我们可以查看查询生成的结果集。

返回报告服务 ( Back in Reporting Services )

We right click upon the “Reports” folder and select “Add” and “New Item”.

我们右键单击“ Reports”文件夹,然后选择“ Add”和“ New Item”。

We select “Report” and give our report a name “DatesOnTheFlySubReport”. We click “Add” and we are brought into the “DatesOnTheFlySubReport” subreport drawing surface (see below).

我们选择“报告”,并将报告名称命名为“ DatesOnTheFlySubReport”。 单击“添加”,然后将其带到“ DatesOnTheFlySubReport”子报表工程图表面(请参见下文)。

We add a “Matrix” report item from the tool box (see above).

我们从工具箱中添加了一个“矩阵”报告项(见上文)。

We now must create dataset. Should you be unfamiliar with the concept of “data sources” and “data sets” please do you

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
SQL Server 用代码创建报表,你需要使用 Reporting Services API。下面是一个简单的示例,演示如何创建一个报表: ```csharp using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Microsoft.Reporting.WebForms; namespace ConsoleApp1 { class Program { static void Main(string[] args) { // 创建一个报表对象 var report = new LocalReport(); // 设置报表的数据源 var ds = new ReportDataSource("DataSet1", GetDataTable()); report.DataSources.Add(ds); // 设置报表的路径和名称 report.ReportPath = "Report1.rdlc"; // 渲染报表 var result = report.Render("PDF"); // 保存报表到文件 System.IO.File.WriteAllBytes("Report1.pdf", result); } // 获得报表数据源的示例方法 private static System.Data.DataTable GetDataTable() { var dt = new System.Data.DataTable(); dt.Columns.Add("Name"); dt.Columns.Add("Age"); dt.Rows.Add("张三", 20); dt.Rows.Add("李四", 30); dt.Rows.Add("王五", 40); return dt; } } } ``` 在这个示例,我们首先创建了一个 `LocalReport` 对象,并设置了它的数据源。然后,我们指定了报表的路径和名称,并调用 `Render` 方法将报表渲染为 PDF 格式。最后,我们将渲染后的报表保存到文件。 当然,这只是一个简单的示例。实际上,根据你的具体需求,你可能需要设置更多的报表属性,如报表布局、样式、参数等。如果你需要更详细的指导,可以参考 SQL Server 的官方文档或相关教程。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值