Crystal Report grouping end of page - c#

I have a crystal reports with grouping, there are about 3 to 4 groups per page.
But at the end of the page a group is split between two pages, and sometimes there is only the group name, but the group details are on the other page.
I was wondering if there is a way to force ONLY the group that spans 2 pages to start at the next page.
I'm using the C# with visual studio 2008.
Regards,

The simple answer is to start a new page on each change of group.
There isn't an easy way to determine whether the combination of group header, group details and group footer would be split over two pages (so that you can then start a new page for the group header). The normal way to deal with this is to check the "keep together" option in each of the group sections (as described by Kangkan), and to repeat header items where necessary in page headings.
There is a complicated way to do this - by determining how much has already been printed on the current page, then calculating how large the next combined group will be and entering a conditional formula in the Group Header section against the New Page Before option. However, it is quite tricky to write and hard to maintain, as the conditional paging formula will need to be re-written if there is any change to the length of any of the sections in question.
EDIT - repeating group header items in page headers -
Say you wanted to repeat the grouping item under the column headings, where a group was split over two pages:
Split the existing page heading section into two subsections, with the column headings in the first subsection;
Add the grouping item to the second page heading subsection;
In the section expert, set the conditional formula for the Suppress (No Drill-Down) option for the second page heading subsection to be RecordNumber = 1 or Previous ({fieldname}) <> {fieldname}

There is an option to set it and it is called "Keep together". See the property page (in the section expert) for the group and check the "Keep together" option. This will solve your issue.
Also, there are options for "New page before" and "New page after" for every section. You can insert a page break accordingly.
As Mark said, it is very complicated to find out whether a group (along with its content and footer) will be accommodated in the remaining part of the page. So, the natural way is to start a group from a new page and to repeat the group in the page header if required.

Related

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.

Repeat header based on user choice

I have a report subreport with a group and the option "Repeat group header in each page" checked. But I need the user to be able to choose whether or not to show the group header on every page, or just the first time the group appears.
I set up a checkbox to let them choose, but how can I use this to tell the report not to repeat the header during run time?
Update
Beeing a Subreport I can not know which page will appear for the first time and I can not restart the numbering because it is necessary for the report.
I'm using CrystalReports in VS2005 and coding C# in VS2010, I'm working for a company and can't upgrade.
I'm trying to use a FormulaFieldDefinition in C# but I don't know how.
This could be done with a variable inside the sub-report.
Create a formula-field with following content and place it somewhere in the detail-section:
WhilePrintingRecords;
booleanVar headerPrinted := True;
In the suppresion-formula of the group-header place the following code:
WhilePrintingRecords;
booleanVar headerPrinted;
The formula will set the variable to True as soon as the first detail is being printed.
So the suppression formula evaluates to False only the first time the group header is being printed and to True on every subsequent time.
So with a boolean parameter {?GroupHeader} to choose if the header should be printed or not the suppression-formula would look as follows:
WhilePrintingRecords;
booleanVar headerPrinted;
If {?GroupHeader} And headerPrinted Then
True
Else
False
{?GroupHeader} = True would mean: Only show group-headers once.
I'm not sure which version of Crystal Reports you are using, but it does not look like there is an ability to specify a formula for "Repeat Group Header on each Page" under the Group Expert in Crystal 2011.
Instead, you might have to do a work around:
Create a boolean parameter {?GroupHeader} where true means "show the group header on every page."
Create a page header.
Copy your group header elements into the new page header.
Create a suppression formula on the new page header section under the Section Expert.
if PageNumber > 1 and {?GroupHeader} = true then false else true.

Using Word Interop, how does one tell if a table is going to span multiple pages?

Is there any way to catch a break in the table in order to insert a "Continued on next page" row? I've tried checking each row to see if the HeaderFormat is -1 (as I set headers to repeat on subsequent pages), but that doesn't work. I suppose I could count rows and guestimate, but I'd rather have an exact point at which to insert the new row at the bottom of the table before it breaks onto another page.
I found a solution. This post describes how to find the page number from a range. You can call this with the range of a row and check when the page changes. When the page changes go back a row index and add the "Continued..." text.

How to display headers on multiple pages using syncfusion

I have a table report which will be exported as a word document. I can print out the header in the first page only. It doesn't seem to carry over to the next page. Can anyone tell me how I can show the header data on all the pages of the word document?
The solution to this was a lot easier than I expected. All I had to do was put the header data I wanted in the header of the Word Ddocument Template that I wanted to use. Also in order to have the header of a table to apear repeatedly when there are multiple pages, again we go to the Word Document Template, select the rows you want to use as headers then right click and go to Properties -> Rows tab -> enable(check) "Reapeat as header row at the top of each page" -> click OK and save. That should do the trick!! Then use syncfusion as you usually use it to populate the table. When the data exceed to more than one page the header will be repeated on the following pages.

Pagination in a rdlc report

How can I set the pagination or the number of items being displayed in a single page? Suppose there are 1000 items and at each page I want to show 100 and use a next button to navigate to the next page . How can I be able to do that, Please discuss it in c# context .
Thank You.
You can do this by using PageBreaks.
From MSDN:
Page Breaks
In some reports, you may want to place
a page break at the end of a specified
number of rows instead of, or in
addition to, on groups or report
items. To do this, create a group in a
data region (typically a group
immediately outside the detail), add a
page break to the group, and then add
a group expression to group by a
specified number of rows.
The following expression, when placed
in the group expression, assigns a
number to each set of 25 rows. When a
page break is defined for the group,
this results in a page break every 25
rows.
=Int((RowNumber(Nothing)-1)/25)
Taken from http://msdn.microsoft.com/en-us/library/ms251668(VS.80).aspx

Categories