问题
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.
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:
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?
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.
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.
回答1:
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:
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
Next i created a new WindowsFormsApplication and added a new item "Report" (not Report Wizard)
From the Toolbox i added a new Table followed the wizard to connect to the sample data previously created
Added Population and Data to the table and deleted the extra column so your left with something looking like this:
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"
Now Delete the newly created column, making sure you select to delete the column only not the group
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
Add a new Row between the two rows, by Right Clicking (Details) under Row Groups, Add Total > Before
In the new row add the row headers, Should be left with something like this:
Switched over to the Form.cs [Design], Added a ReportViewer from the ToolBox, Choose the newly created report
Preview of the Final Solution was as follows
Next steps would be to update the formatting of the report
来源:https://stackoverflow.com/questions/13426616/what-is-the-easiest-way-to-make-a-banded-report-in-rdlc