在RDLC中制作“带状”报告的最简单方法是什么?

时间:2022-08-22 08:05:17

Okay, I may have been googling for the wrong search terms but I can't find how to make a MS-Access style banded report with RDLC (that is the crippled report designer in Visual Studio 2010, not BIDS) And by banded I mean, a report with group headers and sub group headers-- not alternating bands of color.

好吧,我可能一直在谷歌上搜索错误的搜索条件,但我找不到如何使用RDLC制作MS-Access风格的带状报告(这是Visual Studio 2010中的残缺报表设计器,而不是BIDS)并且带状我是说,一个包含组头和子组头的报告 - 不是交替的颜色带。

I have a toolbox with a List, Tablix and Matrix, which sort of all behave the same- I keep getting things that look like MS-Access CrossTabs. I can get this:

我有一个带有List,Tablix和Matrix的工具箱,它们的行为都相同 - 我不断得到看起来像MS-Access CrossTabs的东西。我可以得到这个:

Country Population    Date
---------------------------
Spain 1 million     1982
Spain 1.1 million   1983
China 1 billion     1982
China 1.2 billion   1983

I can also get countries on rows, years on columns and pop in the center, like cross tab, but I don't want a cross tab. Also, I don't want row headers, which really is just the same as above, except identical cells are merged.

我也可以在行上获取国家,在列上显示年份并在中心弹出,例如交叉表,但我不想要交叉表。此外,我不想要行标题,除了相同的单元格合并之外,它们与上面的标题完全相同。

But I can't get this:

但我不能得到这个:

---------------
Spain 
---------------
Population     Date
1 million     1982
1.1 million     1983
---------------
China
---------------
Population    Date
1 billion     1982
1.2 billion   1983

Is it even possible with RDLC?

甚至可以用RDLC吗?

More Info Reporting Services is a server product that Microsoft publishes that comes with a client call Business Intelligence Development something something or BIDS for short. The former consumes RDL and the later produces RDL (RDL is a XML based reporting language). I don't have either of those.

更多信息Reporting Services是Microsoft发布的服务器产品,随客户端调用Business Intelligence Development,简称BIDS。前者使用RDL,后者生成RDL(RDL是基于XML的报告语言)。我没有其中任何一个。

I have ReportViewer, which is an ASP.NET control that can read RDLC (a crippled subset of RDL) and I have Visual Studio 2010 which has a crippled version of BIDS. The toolbox in Visual Studio 2010 has a list, a Tablix and a Matrix, which all appear to be the same control with different default starting properties. It is effortlessly easy to create what in MS-Access are called Crosstabs, but trial and error to produce a banded report that groups tends to produce anything but.

我有ReportViewer,它是一个ASP.NET控件,可以读取RDLC(RDL的一个残缺的子集),我有Visual Studio 2010,它有一个残缺的BIDS版本。 Visual Studio 2010中的工具箱有一个列表,一个Tablix和一个Matrix,它们看起来都是具有不同默认启动属性的相同控件。在MS-Access中创建名为Crosstabs的东西很容易,但是试错会产生一个带状报告,群组往往会产生任何东西。

1 个解决方案

#1


7  

As long as I've understood everything, what you are asking is achievable in RDLC format, i performed the following steps to get your desired output:

只要我了解了所有内容,您要求的是RDLC格式可以实现的,我执行以下步骤来获得您想要的输出:

  1. Firstly I created sample data to play with using the data example you provided above.

    首先,我使用您在上面提供的数据示例创建了样本数据。

    CREATE TABLE [dbo].[SampleTable](
        [Country] [nchar](10) NULL,
        [Population] [nchar](20) NULL,
        [Date] [nchar](10) NULL
    ) ON [PRIMARY]
    
    GO
    
    INSERT INTO [SampleTable]([Country],[Population],[Date])
    SELECT 'Spain', '1 million', '1982'
    UNION ALL SELECT 'Spain', '1.1 million',   '1983'
    UNION ALL SELECT 'China', '1 billion',     '1982'
    UNION ALL SELECT 'China', '1.2 billion',   '1983'
    
    GO
    
  2. Next i created a new WindowsFormsApplication and added a new item "Report" (not Report Wizard)

    接下来我创建了一个新的WindowsFormsApplication并添加了一个新项目“Report”(不是Report Wizard)

  3. From the Toolbox i added a new Table followed the wizard to connect to the sample data previously created

    从工具箱中我添加了一个新的表,跟随向导连接到先前创建的示例数据

  4. Added Population and Data to the table and deleted the extra column so your left with something looking like this:

    向表中添加了人口和数据并删除了额外的列,因此您的左侧看起来像这样:

    在RDLC中制作“带状”报告的最简单方法是什么?

  5. Add a Group, by Right Clicking on (Details) under Row Group, Add Group > Parent Group...

    右键单击行组下的(详细信息),添加组>父组...添加组...

    Dialogue Box - Tablix Group: Group by: Country, Tick "Add group header"

    对话框 - Tablix组:分组依据:国家,勾选“添加组头”

  6. Now Delete the newly created column, making sure you select to delete the column only not the group

    现在删除新创建的列,确保选择仅删除列而不删除组

  7. Delete the column header row and add the Country field in the blank Row (click on the table icon that appears when hovering over the field), can also Merge the cells by right clicking as well

    删除列标题行并在空白行中添加“国家/地区”字段(单击悬停在字段上时显示的表格图标),也可以通过右键单击合并单元格

  8. Add a new Row between the two rows, by Right Clicking (Details) under Row Groups, Add Total > Before

    通过在“行组”下的“右键单击(详细信息)”,“添加总计”>“之前”,在两行之间添加新行

  9. In the new row add the row headers, Should be left with something like this:

    在新行中添加行标题,应该留下如下内容:

    在RDLC中制作“带状”报告的最简单方法是什么?

    在RDLC中制作“带状”报告的最简单方法是什么?

  10. Switched over to the Form.cs [Design], Added a ReportViewer from the ToolBox, Choose the newly created report

    切换到Form.cs [Design],从ToolBox添加ReportViewer,选择新创建的报告

  11. Preview of the Final Solution was as follows

    最终解决方案的预览如下

    在RDLC中制作“带状”报告的最简单方法是什么?

Next steps would be to update the formatting of the report

接下来的步骤是更新报告的格式

#1


7  

As long as I've understood everything, what you are asking is achievable in RDLC format, i performed the following steps to get your desired output:

只要我了解了所有内容,您要求的是RDLC格式可以实现的,我执行以下步骤来获得您想要的输出:

  1. Firstly I created sample data to play with using the data example you provided above.

    首先,我使用您在上面提供的数据示例创建了样本数据。

    CREATE TABLE [dbo].[SampleTable](
        [Country] [nchar](10) NULL,
        [Population] [nchar](20) NULL,
        [Date] [nchar](10) NULL
    ) ON [PRIMARY]
    
    GO
    
    INSERT INTO [SampleTable]([Country],[Population],[Date])
    SELECT 'Spain', '1 million', '1982'
    UNION ALL SELECT 'Spain', '1.1 million',   '1983'
    UNION ALL SELECT 'China', '1 billion',     '1982'
    UNION ALL SELECT 'China', '1.2 billion',   '1983'
    
    GO
    
  2. Next i created a new WindowsFormsApplication and added a new item "Report" (not Report Wizard)

    接下来我创建了一个新的WindowsFormsApplication并添加了一个新项目“Report”(不是Report Wizard)

  3. From the Toolbox i added a new Table followed the wizard to connect to the sample data previously created

    从工具箱中我添加了一个新的表,跟随向导连接到先前创建的示例数据

  4. Added Population and Data to the table and deleted the extra column so your left with something looking like this:

    向表中添加了人口和数据并删除了额外的列,因此您的左侧看起来像这样:

    在RDLC中制作“带状”报告的最简单方法是什么?

  5. Add a Group, by Right Clicking on (Details) under Row Group, Add Group > Parent Group...

    右键单击行组下的(详细信息),添加组>父组...添加组...

    Dialogue Box - Tablix Group: Group by: Country, Tick "Add group header"

    对话框 - Tablix组:分组依据:国家,勾选“添加组头”

  6. Now Delete the newly created column, making sure you select to delete the column only not the group

    现在删除新创建的列,确保选择仅删除列而不删除组

  7. Delete the column header row and add the Country field in the blank Row (click on the table icon that appears when hovering over the field), can also Merge the cells by right clicking as well

    删除列标题行并在空白行中添加“国家/地区”字段(单击悬停在字段上时显示的表格图标),也可以通过右键单击合并单元格

  8. Add a new Row between the two rows, by Right Clicking (Details) under Row Groups, Add Total > Before

    通过在“行组”下的“右键单击(详细信息)”,“添加总计”>“之前”,在两行之间添加新行

  9. In the new row add the row headers, Should be left with something like this:

    在新行中添加行标题,应该留下如下内容:

    在RDLC中制作“带状”报告的最简单方法是什么?

    在RDLC中制作“带状”报告的最简单方法是什么?

  10. Switched over to the Form.cs [Design], Added a ReportViewer from the ToolBox, Choose the newly created report

    切换到Form.cs [Design],从ToolBox添加ReportViewer,选择新创建的报告

  11. Preview of the Final Solution was as follows

    最终解决方案的预览如下

    在RDLC中制作“带状”报告的最简单方法是什么?

Next steps would be to update the formatting of the report

接下来的步骤是更新报告的格式