Report Viewer: Dynamic header content by value in DataSet - c#

Sorry that I can't think of a good title for my question.
I am creating a C# report with report viewer and I am passing the report with data like below:
Product Selling Date Quantity
Pen 1-1-2015 2
Pen 1-2-2015 5
Pencil 1-1-2015 5
Pencil 1-2-2015 3
And I want to display ONE report with each "Product" showing as a header
Example:
Product: Pen
Selling Date Quantity
============ ========
1-1-2015 2
1-2-2015 5
Product: Pencil
Selling Date Quantity
============ ========
1-1-2015 5
1-2-2015 3
Can report viewer fulfill this requirement?
Note: I am using VS2013.
I have found a video for VB exactly fulfilling my requirement, but I can't find similar button "Edit detail group" in C#.
Thanks,
Steven

So I got the answer. Let's start from the very beginning.
In Report Viewer, insert a table.
Highlight the table's data row > Add Group > Parent Group
In the dialog popped up, select Group by "Product" in my case. A column "Product" will be added in the table
You can also do further grouping, say by the product's brand, by selecting the "Product" column > Add Group > Child Group > Group by "Brand"
Remove the auto added columns without removing the group.
Put your data (selling date and quantity) in the data row.
To add the header (Product: Pen), right click on the data row > Inside Row > Inside Group - Above
In the newly inserted row, put the product field in it.
Done.

Related

RDLC showing additional Rows in a table

I am creating a Report on RDLC. Lets say i have 2 tables in database where im importing data from users and expenses.
Each user can have multiple Expenses. Expenses contain Details and amount just 2 columns that i have to include in the report.
Ive created a stored procedure but its duplicating rows because of having same UserId in expenses. So far im able to achieve this.
See This Picture
What i wanted is that One row with column bulty id and other details with multiple sub rows of expenses.
How can i achieve this. I've tried hide duplicate property in RDLC but its showing duplicate column fields
This is what i wanted to achieve
See image
in this case, I use matrix tool in RDL file.
you should set expenses the ColumnGroup of the matrix
Solved it by doing the Master/Detail Approach. Put 2 tablix in the list. on the first tablix set user details and made a row group so that the values dont repeat and then on the second tablix used the additional data fields.
Then dragged this additional data tablix into the row of first tablix and everything seems to work just fine.
For serial numbering i used Counting distinct values according to my userid

How to load two RDLC reports in same report viewer?

I have two reports the first one to show general information and the second one to show details and I need to show each one in a different page in report viewer
can you help me to do that
thanks
like the image
Hopefully, the following can help guide you into what you are looking for. First, you will need THREE reports and TWO datatables (or other lists as you have to build your report).
First, On the 3 reports I describe, I would not worry about any of the report final formatting to be perfectly aligned, bold, spacing... get it to work, then you can make it pretty after all is functional.
Next, create a bogus datatable "MyTable" for the sole purpose of creating two records. Even if a single column of "MyGroup" and having it as an int (just for sample purposes).
Now, create two records and set the values in each row to 1 and 2 respectively so your table has
MyGroup
1
2
Now, for the other two reports. It is my understanding that you want the first report to show a summary of each department's totals with a grand-total. The second report is showing the details of all the activity per department. So this is basically using the same dataset returned from whatever query. For this example, I will refer to the datatable as "SalesData".
CREATING THE REPORTS
Create your first report, put a table control on the report, full width you will have for your current reports as landscape or portrait as long as both the same size, you want this report to be the same. Ex: ALL will be portrait. Add your Report Data source to show the "MyTable" and assign that to the table control. Also add the "SalesData" table to the report as well so it is available to the future sub-reports.
On the table control, below where it shows the "Row Groups", add a "Group By" for the "MyGroup" column. This is so we can force a page-break between each group. Once added, right-click on the parent group "MyGroup" and select "Group Properties". This will show an option on the left side to allow you to set page breaks, click the checkbox for "Between each instance of a group". For now, just have the one column in the table control as the "MyGroup" column. Save the report ex: "MySalesRpt.rdlc". Then compile and run the report. You should get this simple report with 2 pages, each showing just the number 1 and 2 respectively. NOTE: You will also want to add the datatable reference for your secondary reports to this main report as well so they are available as sub-reports of the first.
Create a new report ex: "MySalesDetail.rdlc", add the "SalesData" to it. Add a table control to the report and set its source to the "SalesData" table. Include whatever for your detail columns you want to show of the sales activity. Add a data group based on the department, get your sum( salesDollarColumn ). Add a new row outside/below the group footer so you can have the report grand totals as a sum of all ex: SalesDollarColumn. You can test and run this report on its own until it looks correct.
Now, your third report. Copy/paste the MySalesDetail.rdlc report and change it to MySalesSummary.rdlc. So you don't this summary report showing every row that builds the grand total sum() per each department, right-click on the row that represents the details of the group and delete. It will ask if you want to delete rows and associated groups? Reply yes as it will just remove the details row, but keep the group footer that will retain your sum() total per department. Save, test / run this report.
Once all 3 reports work individually, now we can go back to the "MySalesRpt". Add an additional DETAIL row in this otherwise simple 1-detail report. Right-click on the existing detail row and then pick "Insert Row" -> "Inside Group - Below". This will now show as two rows.
Now, in the first row of the report where it did have just a simple textbox, go to your report Toolbox and pick Subreport and put one instance into each row.
On the first row, subreport, right-click and set properties. Set both the Name and "Use this report as a subreport" to the summary report "MySalesSummary". On the second row subreport, do the same but with "MySalesDetail".
Final step. Click on the Subreport representing the "MySalesSummary". Go to the properties of that and scroll down to the "Hidden" property. You want to have this value set to the expression: ex: "=Fields!MyGroup.Value = 2". This way the report will ONLY be generate when it is on the first record where MyGroup = 1.
Similarly, on the second subreport representing the detail, set the hidden equal to the opposite.. "=Fields!MyGroup.Value = 1". Hide when the MyGroup = 1. This way you can have each report on their own page, but only one will show up per group.
I know is sounds deep, but do it slowly and it should work for you. I already did and confirmed this process works. Sorry so many steps, but it has to be broken into multiple parts to tie them all together as you are requesting.
One rdlc in main local report and the other in subreport. Then set InteractiveSize in the main local report to break it to show each one in a different page in report viewer.

Report Viewer with custom Column and Fields

So first this is my schema my master
so details contain 3 foreignkey from color model and size
for example this is my data in item details
so i wanna create my report rdlc like this
so my question is how to create report like that and how to add column according much data Size i have in that report if after query item details that item and model only have 3 size so only show 3 column size and if i only have 2 size only have 2 column at upper report . same condition with color
if have size for example medium but color is null so in report show empty or "-"
note : for date is empty space for manual reporting
Create a new report and add your dataset.
Add a Matrix control to your report. The new matrix control will have cells marked for 'Rows', 'Columns' and 'Data' like below
Drag the COLOR_NAME field from the dataset onto the 'Rows' cell, drag SIZE onto 'columns' and QTY onto data.
If you run your report now you will get a basic version of what you want.
To add the extra row you need, right-click the SIZE Column and do 'Insert Row' -> Inside Group - Below
Next, right click the cell that was just a created and do 'Insert Column' -> 'Inside Group - Right'.
Type you r headers ('qty' and date) in the respective columns
Finally, the size column groups are sorted alphabetically so we need to change them, luckily we can just reverse the order with real data I suggest you supply a sorting field in your dataset so you can sort the columns how you wish.
To reverse the sort order, Click the drop down next to the SIZE column group in the area just below the report design and choose 'Group Properties'. Click 'Sorting' and then change the Order to Z-A
Now the final report design looks like this.
A few tiny formatting updates to center things and the final output looks like this.

Split rows by name

My stored procedure gets info from SQL DB. Now I want to add the info to a crystal report and display the PDF with all the details.
I use Visual Studio with Crystal reports installed, coding in C# using Dataset to get my info from SQL. The info is a list of names with 3 other details that goes with those names (columns). At times it can be one name as a result, or it can be 3 names as a result.
My aim is to have a table on the report, and each table row lists a name in the first column, then in the 3 consecutive columns its corresponding details. Same look to the SQL table you get when pulling the info.
To setup the individual columns is easy, drag each field onto the report. But how can I split the names so that I have one name listed per table row? This is the result from query:
I want to populate it into my Crystal form which looks like this:
The solution that I have ended up with was to create a sub report, place it on top of the table I have created in my second picture. Then added the columns to the sub-report, took away any borders. And then between the container size on the report and with the paragraph options of the container I adjusted the line spaces. Now if I have more than one row in the list, it appears on each line as needed.

Insert page break for each month in crystal report

I am working on crystal reports in c#.
while printing sales report I want to insert a page break for every new month.
you have to set the property that.
select group section -> select option tab -> insert 1 in the text box of the filed name new page after 1 visible group
Thus your problem should be solve.

Categories