使用.rpt中的参数将.rpt导出为asp.net中的pdf

时间:2016-06-23 18:01:06

标签: asp.net

先谢谢你的帮助。

我是这个网站的新手。

我需要创建一个将.rpt导出为pdf的过程。我在.rpt中使用参数,因为我使用sql存储过程来创建报告。

我正在使用vb。

在asp.net 2008中开发

问候。

1 个答案:

答案 0 :(得分:0)

我解决了我的问题。

这是代码,因为如果你需要它。

问候。

    Dim PathFile As String = "c:\Documents" & "\Reporte.pdf"

    formatType = ExportFormatType.PortableDocFormat

    Dim oConexInfo As New CrystalDecisions.Shared.TableLogOnInfo
    oConexInfo.ConnectionInfo.ServerName = "SERVER"
    oConexInfo.ConnectionInfo.DatabaseName = "DBNAME"
    oConexInfo.ConnectionInfo.UserID = "USERID"
    oConexInfo.ConnectionInfo.Password = "PASSWORD"

    rpt.Load(Server.MapPath("~/Imprime.rpt"))

    rpt.SetParameterValue(0, Val(txt_No_Quotation.Text))   ' I send a parameter value
    rpt.Database.Tables(0).ApplyLogOnInfo(oConexInfo)      ' Here I send the credentials for conection to SQL Server with crystal reports

    CrystalReportViewer1.ReportSource = rpt
    ConfigureCRTSTALREPORT()

    rpt.ExportToDisk(formatType, PathFile)     ' Here I export the pdf to disk (in server side)