logo
small logo
  • Produkte
  • Shop
  • Support
  • Articles
  • Customer panel Support
    • en
    • pt
    • es
    • de
    • pl
    • JP
    • ZH
  • Home
  • /
  • Articles
  • /
  • How to make the same report pages with different headers
  • So organisieren Sie Vererbung der Reporte in FastReport .NET

    29. Januar 2021

    Wenn Sie angewiesen werden, eine große Anzahl von den Reporten innerhalb desselben Unternehmensstils zu erstellen,

    read more
  • Wie man automatisch Standard-E-Mail-Client-Einstellungen für das Senden von E-Mails aus FastReport .NET setzt

    12. Februar 2021

    Wie bei vielen anderen Reportgeneratoren können Sie mit FastReport .NET einen Report per E-Mail in

    read more
  • Wie wird das Objekt WebReport in ASP .Net Core App verwendet?

    17. Januar 2018

    Neulich veröffentlichte Fast Reports eine neue Bibliothek für die Arbeit mit dem Framework ASP .Net

    read more
  • Wir machen und geben ITF-14-Barcodes in .NET-Anwendungen aus

    25. Februar 2021

    ITF-14 (Interleaved Two of Five) ist ein zweispuriger numerischer Code, mit anderen Worten Code mit

    read more
  • Wie ein WebReport-Objekt in FastReport.Core aktualisieren

    21. September 2020

    Manchmal gibt es eine Aufgabe, den Report zu aktualisieren, z. B. wenn Sie einen neuen

    read more

How to make the same report pages with different headers

8. Januar 2020

Sometimes your work needs one and the same report, but with a few changes. For example, different headers for different departments. So, for example, a user of the ActiveReports report generator wants to create such a report:

For example, the user select copies for the customer and for administration department.

The application creates the same report but each one has a label in the header that shows something like "Copy for the customer", "Copy for the administration department".

After, the application has to show the two pages in a form viewer.

Let's implement such a report in FastReport.Net. You can generate the same report and pass it different parameters for the header. But if you want to receive similar reports with different headlines in one report, you can do otherwise. We can duplicate the pages of the original report, and then modify the headers in these pages. The easiest way is to show on the report with one page.

The report will have a parameter that lists the number of titles that you want to display in this report through a comma. In the report script, we duplicate the page based on the number of values in the setting, then replace the text in the headlines of the new pages to the desired.

In this way, we can form pages with different titles depending on the numbers that are transferred. However, there is one difficulty. You'll have to manually calculate the number of the text object in which you want to replace the text. For example, there are 9 text objects in my report. The first is the headline. So the tenth will also be the headline, but on the new page. If you add another 9 to 10, we get the title number on the third page and so on.

It will become more clear when you the script code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
private void _StartReport(object sender, EventArgs e)
 {
 //Parse parameter
 string parameter = (string)Report.GetParameterValue("Parameter");
 string[] arr = parameter.Split(',');
 
 //Number of text obj that is header
 int step = 10;
 
 foreach (string item in arr)
 {
 ReportPage newPage = new ReportPage();
 newPage.AssignAll(Page1);
 Report.Pages.Add(newPage);
 newPage.CreateUniqueName();
 foreach (object obj in newPage.AllObjects)
 {
 if (obj is Base)
 { 
 (obj as Base).CreateUniqueName();
 }
 }
 TextObject txt = Report.FindObject("Text"+ step.ToString()) as TextObject;
 switch (item)
 {
 case "1":
 txt.Text = "Header 1"; 
 break;
 case "2":
 txt.Text = "Header 2"; 
 break;
 case "3":
 txt.Text = "Header 3"; 
 break;
 }
 step = step + 9;
 }
 Report.Pages.Remove(Page1);
 }

 Let's take a closer look at this script. We used the StartReport event at the Report object. In the event handler, we will manipulate the report pages. The report already has one page developed - in fact it is a ready-made "combat" report, on the basis of which we want to make several, but with different headlines.

First of all, we parse a report parameter. As mentioned earlier, the parameter is passed in sequence identifier patterns that we want to display. Identificators are separated by commas. Next, iterate loop parameter IDs obtained from the report. For each of them creates a page based on an existing text object is calculated with a header. Depending on the text object header template identifier is set. Once we have established a "pack" the necessary pages, remove the first page of the sample.

As a result, we get multiple reports within a single. A controlled number of these reports pages may be passing in the report parameter value - the desired combination of identifiers or headers.

 

about product download buy
avatar
Dmitriy Fedyashov
Technical Writer
Fast Reports Team: Dmitriy Fedyashov - Technical Writer at Fast Reports
.NET FastReport

Add comment
logo
  • 800-985-8986 (English, US)
  • +4930568373928 (German)
  • +55 19 98147-8148 (Portuguese)
  • info@fast-report.com
  • 901 N Pitt Str #325 Alexandria VA 22314
  • Shop
  • Download
  • Dokumentation
  • Referenzen
  • Informationen zur Deinstallation unserer Produkte
  • Ticket system
  • FAQ
  • Tutorial Video
  • Forum
  • Articles
  • Unsere Nachrichten
  • Presse über uns
  • Partner
  • Außergewöhnliche Lizenzierung
  • Kontakte

© 1998-2022 by Fast Reports Inc.

  • Datenschutz