This is a migrated thread and some comments may be shown as answers.

Print report without displaying it?

5 Answers 197 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Julien
Top achievements
Rank 1
Julien asked on 23 Oct 2011, 07:24 AM
Hi,

I've a telerik report in a reportview, which is working great, from here I can print/export/...

But I need to print the report without displaying it in a reportviewer. How can I do that?

Another related question: I've one report that I need to print several time(more than 400) with different data, is there a way to print all reports in only one "print job".

Thank you!

5 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 25 Oct 2011, 03:25 PM
Hi Julien,

You've not mentioned the most important thing - which report viewer are you using (we have one for each platform).
If you prepare the data so it could be used in a single Data Source Component, then you can print it as one job as it would be separated based on a certain group criteria. You can even apply PageBreak after/before a certain report section so that the data for each group is on a separate page. Another option is to utilize the Report Book functionality and add each reports you need to print to its collection (or in your case the same report with different data source) and then print the report book.

Best wishes,
Steve
the Telerik team

Q2’11 SP1 of Telerik Reporting is available for download (see what's new). Get it today.

0
Julien
Top achievements
Rank 1
answered on 25 Oct 2011, 03:35 PM
Hi,

I'm using the WPF viewer, sorry.

In the report I declared an objectDataSource, which I put in my business object. I will take a look about the Report book, seems to be what I need. How can I set the dataContext to my report when I create those reportbook?

I can't use parameters because the type of my parameter has to be a business object and it seems you accept only primary types

So how to print without displaying anything
0
Steve
Telerik team
answered on 27 Oct 2011, 02:47 PM
Hello Julien,

You can instantiate a custom ReportBook with parametrized constructor. Based on the constructor's parameter you can instantiate the required report definitions and set their parameters as shown in the following code snippet:
Copy Code
public class ReportBook : Telerik.Reporting.ReportBook
{
    public ReportBook(int[] ids)
    {
        foreach (int id in ids)
        {
            var report = new Invoice();
            report.ReportParameters["InvoiceID"].Value = id;
            this.Reports.Add(report);
        }
    }

Generally the reports' parameters are merged. In order to avoid this our suggestion is to set ReportParameter.Mergeable to false.

You may find useful the ReportBook class used in the demos that came with your installation of Telerik Reporting. (start -> All Programs -> Telerik -> Reporting Q2 2011 -> Visual Studio 2010 Examples )

Then to print the report book, you can use the PrintReport Method method of the ReportProcessor class.

Kind regards,
Steve
the Telerik team

Q2’11 SP1 of Telerik Reporting is available for download (see what's new). Get it today.

0
Julien
Top achievements
Rank 1
answered on 27 Oct 2011, 03:17 PM
Like I just said before, I can't use parameter, since the object I need to give to the user isn't in accessible once I'm in the report, I need to give the object directly in the data source.

Thanks
0
Steve
Telerik team
answered on 28 Oct 2011, 04:17 PM
Hello Julien,

Sorry if we've got confused by your description. In order to understand better your scenario and the need to pass business object to our ObjectDataSource Component, can you for the sake of example explain how you would do this with another databound control i.e. Grid? Is the object the data source you want to use? If that is the case, one possible approach would be to create a parametrized method that gets the data from your object and use that method as DataSource for the report. The parameters for this method can be provided through the Report Parameters.
For more information refer to Using Parameters with the ObjectDataSource Component.

Regards,
Steve
the Telerik team

Q2’11 SP1 of Telerik Reporting is available for download (see what's new). Get it today.

Tags
General Discussions
Asked by
Julien
Top achievements
Rank 1
Answers by
Steve
Telerik team
Julien
Top achievements
Rank 1
Share this question
or