【问题标题】:How to export Telerik ReportViewer to PDF without going to the preview. VB.net webforms如何在不进行预览的情况下将 Telerik ReportViewer 导出为 PDF。 VB.net 网络表单
【发布时间】:2017-05-05 04:27:15
【问题描述】:

This is the report that I want to export to pdf

嗨!如何在不必转到报表查看器窗口的情况下将此报表导出为 PDF?

这是我的代码。这基本上把我带到了报告查看器。我想要做的是当我点击导出按钮时,它直接下载报表而不去报表查看器。

    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

【问题讨论】:

    标签: vb.net pdf webforms report reportviewer


    【解决方案1】:
        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        
    

    【讨论】:

      猜你喜欢
      • 2016-01-20
      • 2011-11-18
      • 1970-01-01
      • 2016-03-26
      • 2017-02-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多