从Crystal Reports Viewer打开pdf

时间:2013-12-06 14:57:30

标签: vb.net crystal-reports-2008

感谢您查看我的问题。我正在使用vb和.net在Visual Studio 2010中构建项目。我有一份Crystal Reports报告,我试图通过点击按钮自动导出并以PDF格式打开。现在我在我的项目中使用Crystal Reports Viewer,它可以很好地打开报告;但是,我希望它只以pdf格式打开。有没有办法做到这一点?

注意:我不是在寻找代码。我想学习,所以如果你能指导我正确的方向,那将是很棒的(如果你不想提供代码)!

感谢您的帮助。

约什

3 个答案:

答案 0 :(得分:1)

我正在使用http://www.codeproject.com/Articles/14549/Crystal-Reports-To-PDF-converter-Without-Crystal-R

中的代码
    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

您需要明确地将变量设置为项目的细节。这些很可能是您想要使用的类和方法。这应该允许您获取水晶报表查看器文件并将其转换为由PDF打开的内容

答案 1 :(得分:1)

这适合我。

  

Dim orpt As CrystalDecisions.CrystalReports.Engine.ReportDocument          orpt = DirectCast(crvInvoice.ReportSource,CrystalDecisions.CrystalReports.Engine.ReportDocument)          orpt.ExportToDisk(ExportFormatType.PortableDocFormat,“PdfFileName.pdf”)

答案 2 :(得分:0)

我发现此链接有助于找到我的解决方案。我希望它可以帮助别人。

http://scn.sap.com/thread/1995379