Vb.net 从Crystal Reports Viewer打开pdf
谢谢你看我的问题。我正在Visual Studio 2010中使用vb和.net构建一个项目。我有一个Crystal Reports报告,我正在尝试自动导出并通过单击按钮打开PDF。现在我在我的项目中使用Crystal Reports Viewer,它可以很好地打开报告;不过,我希望它只能以pdf格式打开。有办法做到这一点吗 注意:我不是来这里寻找代码的。我想学习,所以如果你能指引我正确的方向,那就太好了(如果你不想提供代码的话) 谢谢你的帮助 Josh我使用的代码来自 显然,您需要根据项目的具体情况设置变量。然而,这些很可能是您想要使用的类和方法。这应该允许您将crystal reports viewer文件转换为PDF打开的文件。这对我很有用 Dim orpt As CrystalDecisions.CrystalReports.Engine.ReportDocument orpt=DirectCast(crvInvoice.ReportSource,CrystalDecisions.CrystalReports.Engine.ReportDocument) orpt.ExportToDisk(ExportFormatType.PortableDocFormat,“PdfFileName.pdf”)Vb.net 从Crystal Reports Viewer打开pdf,vb.net,crystal-reports-2008,Vb.net,Crystal Reports 2008,谢谢你看我的问题。我正在Visual Studio 2010中使用vb和.net构建一个项目。我有一个Crystal Reports报告,我正在尝试自动导出并通过单击按钮打开PDF。现在我在我的项目中使用Crystal Reports Viewer,它可以很好地打开报告;不过,我希望它只能以pdf格式打开。有办法做到这一点吗 注意:我不是来这里寻找代码的。我想学习,所以如果你能指引我正确的方向,那就太好了(如果你不想提供代码的话) 谢谢你的帮助 Josh我使用的代码来自 显然,您需要根据项目的具
我建议您尝试找到如何以编程方式将报告导出为PDF。知道路径后,使用
进程.Start(“C:\FilePath\FileName.pdf”)
将其打开。感谢您的帮助!
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Public Class clsCrystalToPDFConverter
Dim ConInfo As New CrystalDecisions.Shared.TableLogOnInfo
Dim oRDoc As New ReportDocument
Dim expo As New ExportOptions
Dim sRecSelFormula As String
Dim oDfDopt As New DiskFileDestinationOptions
Dim strCrystalReportFilePath As String
Dim strPdfFileDestinationPath As String
Public Function SetCrystalReportFilePath(ByVal CrystalReportFileNameFullPath As String)
strCrystalReportFilePath = CrystalReportFileNameFullPath
End Function
Public Function SetPdfDestinationFilePath(ByVal pdfFileNameFullPath As String)
strPdfFileDestinationPath = pdfFileNameFullPath
End Function
Public Function SetRecordSelectionFormula(ByVal recSelFormula As String)
sRecSelFormula = recSelFormula
End Function
Public Function Transfer()
oRDoc.Load(strCrystalReportFilePath) 'loads the crystalreports in to the memory
oRDoc.RecordSelectionFormula = sRecSelFormula 'used if u want pass the query to u r crystal form
oDfDopt.DiskFileName = strPdfFileDestinationPath 'path of file where u want to locate ur PDF
expo = oRDoc.ExportOptions
expo.ExportDestinationType = ExportDestinationType.DiskFile
expo.ExportFormatType = ExportFormatType.PortableDocFormat
expo.DestinationOptions = oDfDopt
oRDoc.SetDatabaseLogon("PaySquare", "paysquare") 'login for your DataBase
oRDoc.Export()
End Function
End Class