TelerikDeveloper.com

TelerikDeveloper.com

sgray128 1/20/2014 10:48:20 AM

ASP.NET - Launching Telerik reports

This is my first foray into Telerik reports, and I'm very pleased. The code below has two parts, launching a report in a web page, and printing the report to a printer ON THE SERVER. Obviously this is not normal ASP.NET functionality; but this was for an intranet and we were printing packing slips to an internal printer.

Great, great functionality.



 

Sub DisplayReport()
    Dim instanceReportSource As New Telerik.Reporting.InstanceReportSource()
 
    Dim oPackingSlip As New PackingSlip
    oPackingSlip.DataSource = SPs.DD_SOPPackingSlip("io-003212", 2).getTable
 
    instanceReportSource.ReportDocument = oPackingSlip
 
    ReportViewer1.ReportSource = instanceReportSource
    ReportViewer1.RefreshReport()
 
End Sub
Sub PrintReport()
    Dim instanceReportSource As New Telerik.Reporting.InstanceReportSource()
 
    Dim oPackingSlip As New PackingSlip
    oPackingSlip.DataSource = SPs.DD_SOPPackingSlip("io-003212", 2).getTable
 
    ' Obtain the settings of the default printer
    Dim printerSettings As New System.Drawing.Printing.PrinterSettings
    ' The standard print controller comes with no UI
    Dim standardPrintController As New System.Drawing.Printing.StandardPrintController
 
    ' Create an instance report source to pass the report to the report processor
    instanceReportSource.ReportDocument = oPackingSlip
 
    ' Print the report using the custom print controller
    Dim reportProcessor As New Telerik.Reporting.Processing.ReportProcessor
    reportProcessor.PrintController = standardPrintController
    reportProcessor.PrintReport(instanceReportSource, printerSettings)
 
End Sub