如何在不进入预览的情况下将 Telerik ReportViewer 导出为 PDF。 VB.net 网络表单
How to export Telerik ReportViewer to PDF without going to the preview. VB.net webforms
This is the report that I want to export to pdf
嗨!如何在不使用报告查看器的情况下将此报告导出为 PDF window?
这是我的代码。这基本上把我带到了报表查看器。我想做的是当我点击导出按钮时,它直接下载报告而不去报告查看器。
Sub DoRep()
Dim truck As String = lblFLPlate.Text
If String.IsNullOrEmpty(truck) Then truck = "-"
Dim db As New wsbl.smwsEntities
Dim rb As New Telerik.Reporting.ReportBook
Dim lstFL = (From p In db.FinalLoadings Where If(p.IsPrinted, False) = False And p.TruckNo = truck And p.FLType = "BST" Order By p.CreatedDate Descending Select p).ToList
For Each fl In lstFL
rb.Reports.Add(getReport(fl.FinalLoadingNumber))
Next
Dim instanceReportSource As New Telerik.Reporting.InstanceReportSource()
instanceReportSource.ReportDocument = rb
ReportViewer1.ReportSource = instanceReportSource
ShowReport()
For Each fl In lstFL
fl.IsPrinted = True
Next
db.SaveChanges()
End Sub
Sub DoRep()
Dim truck As String = lblFLPlate.Text
If String.IsNullOrEmpty(truck) Then truck = "-"
Dim db As New wsbl.smwsEntities
Dim rb As New Telerik.Reporting.ReportBook
Dim lstFL = (From p In db.FinalLoadings Where If(p.IsPrinted, False) = False And p.TruckNo = truck And p.FLType = "BST" Order By p.CreatedDate Descending Select p).ToList
For Each fl In lstFL
rb.Reports.Add(getReport(fl.FinalLoadingNumber))
Next
Dim instanceReportSource As New Telerik.Reporting.InstanceReportSource()
instanceReportSource.ReportDocument = rb
ReportViewer1.ReportSource = instanceReportSource
Dim reportProcessor As New Telerik.Reporting.Processing.ReportProcessor()
Dim result As Telerik.Reporting.Processing.RenderingResult = reportProcessor.RenderReport("PDF", instanceReportSource, Nothing)
Dim fileName As String = result.DocumentName + "." + result.Extension
'Response.Clear()
Response.ContentType = result.MimeType
Response.Cache.SetCacheability(HttpCacheability.Private)
Response.Expires = -1
'Response.Buffer = True
Response.AddHeader("Content-Disposition", String.Format("{0};FileName=""{1}""", "attachment", fileName))
Response.BinaryWrite(result.DocumentBytes)
'Response.End()
For Each fl In lstFL
fl.IsPrinted = True
Next
db.SaveChanges()
ShowMain()
End Sub
This is the report that I want to export to pdf
嗨!如何在不使用报告查看器的情况下将此报告导出为 PDF window?
这是我的代码。这基本上把我带到了报表查看器。我想做的是当我点击导出按钮时,它直接下载报告而不去报告查看器。
Sub DoRep()
Dim truck As String = lblFLPlate.Text
If String.IsNullOrEmpty(truck) Then truck = "-"
Dim db As New wsbl.smwsEntities
Dim rb As New Telerik.Reporting.ReportBook
Dim lstFL = (From p In db.FinalLoadings Where If(p.IsPrinted, False) = False And p.TruckNo = truck And p.FLType = "BST" Order By p.CreatedDate Descending Select p).ToList
For Each fl In lstFL
rb.Reports.Add(getReport(fl.FinalLoadingNumber))
Next
Dim instanceReportSource As New Telerik.Reporting.InstanceReportSource()
instanceReportSource.ReportDocument = rb
ReportViewer1.ReportSource = instanceReportSource
ShowReport()
For Each fl In lstFL
fl.IsPrinted = True
Next
db.SaveChanges()
End Sub
Sub DoRep()
Dim truck As String = lblFLPlate.Text
If String.IsNullOrEmpty(truck) Then truck = "-"
Dim db As New wsbl.smwsEntities
Dim rb As New Telerik.Reporting.ReportBook
Dim lstFL = (From p In db.FinalLoadings Where If(p.IsPrinted, False) = False And p.TruckNo = truck And p.FLType = "BST" Order By p.CreatedDate Descending Select p).ToList
For Each fl In lstFL
rb.Reports.Add(getReport(fl.FinalLoadingNumber))
Next
Dim instanceReportSource As New Telerik.Reporting.InstanceReportSource()
instanceReportSource.ReportDocument = rb
ReportViewer1.ReportSource = instanceReportSource
Dim reportProcessor As New Telerik.Reporting.Processing.ReportProcessor()
Dim result As Telerik.Reporting.Processing.RenderingResult = reportProcessor.RenderReport("PDF", instanceReportSource, Nothing)
Dim fileName As String = result.DocumentName + "." + result.Extension
'Response.Clear()
Response.ContentType = result.MimeType
Response.Cache.SetCacheability(HttpCacheability.Private)
Response.Expires = -1
'Response.Buffer = True
Response.AddHeader("Content-Disposition", String.Format("{0};FileName=""{1}""", "attachment", fileName))
Response.BinaryWrite(result.DocumentBytes)
'Response.End()
For Each fl In lstFL
fl.IsPrinted = True
Next
db.SaveChanges()
ShowMain()
End Sub