how to print automatically without showing the report viewer a telerik report made in vb.net

1 Answer 254 Views
Wizard
Hector
Top achievements
Rank 1
Hector asked on 29 Sep 2022, 07:32 PM
Hello good day,
Help me with this I know it's something simple but I can't find it.
how to print automatically without showing the report viewer a telerik report made in vb.net

the report has a parameter and I would like it to be printed automatically

1 Answer, 1 is accepted

Sort by
0
Justin
Telerik team
answered on 30 Sep 2022, 05:17 PM

Hi Hector,

In order to print a report with parameters, without showing the report in the report viewer, you can use the Report Processor. 

We have some good documentation at Print a Report without displaying it in a report viewer. | Telerik Reporting. Specifically scroll down to the WinForms section and take a look at option number three that discusses the Report Processor. 

If you also want to pass parameters we have another documentation page that shows how to do this with the Report Processor. Generating Reports Locally | Telerik Reporting.

For your convenience, I have combined the approaches together into the following example. 

 

// STEP ONE
// Create ReportProcessor 
var reportProcessor = new Telerik.Reporting.Processing.ReportProcessor();


// STEP TWO
//Depending on the report definition choose ONE of the following REPORT SOURCES

// Option 1 CLR (CSharp) report definitions***
var reportSource = new Telerik.Reporting.TypeReportSource();
reportSource.TypeName = reportName;  // reportName is the Assembly Qualified Name of the report

// Option 2- If you have a TRDP report, use this
//var reportSource = new Telerik.Reporting.UriReportSource();
//reportSource.Uri = "MyReport.trdp";

// Option 3, if you have an instance report, use this
//var reportSource = new Telerik.Reporting.InstanceReportSource();
//reportSource.ReportDocument = new Report1();



// STEP THREE 
//Set any parameters
reportSource.Parameters.Add("SalesYear", 2007);
reportSource.Parameters.Add("SalesPerson", "John Doe");


// STEP FOUR
//Print the report. See docs https://docs.telerik.com/reporting/knowledge-base/print-a-report-programmatically
reportProcessor.PrintReport(reportSource, new PrinterSettings());

 

I understand I the code example is in C#, you can use this code converter to get it in VB. Code Converter C# to VB and VB to C# – Telerik.

Regards,


Justin
Progress Telerik

Brand new Telerik Reporting course in Virtual Classroom - the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products. Check it out at https://learn.telerik.com/.
Tags
Wizard
Asked by
Hector
Top achievements
Rank 1
Answers by
Justin
Telerik team
Share this question
or