【问题标题】:Opening pdf from Crystal Reports Viewer从 Crystal Reports 查看器打开 pdf
【发布时间】:2014-01-22 02:33:55
【问题描述】:

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

注意:我不是在这里寻找代码。我想学习,所以如果你能引导我朝着正确的方向前进,那就太好了(如果你不想提供代码)!

感谢您的帮助。

乔什

【问题讨论】:

  • 我建议您尝试了解如何以编程方式将报告导出为 PDF。知道路径后,使用Process.Start("C:\FilePath\FileName.pdf") 打开它。

标签: vb.net crystal-reports-2008


【解决方案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 打开的内容

【讨论】:

  • 感谢您的帮助!
【解决方案2】:

这对我有用。

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

【讨论】:

    猜你喜欢
    • 2012-04-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多