문제

Thank you for viewing my question. I am building a project in Visual Studio 2010 using vb and .net. I have a Crystal Reports report that I'm trying to have auto export and open in PDF with a button click. Right now I am using Crystal Reports Viewer in my project which opens the report fine; However, I would like to have it only open in a pdf format. Is there a way to do this?

Note: I'm not here hunting for code. I'm wanting to learn, so if you could just guide me in the right direction, that will be great (if you don't want to provide code)!

Thank you for the help.

Josh

도움이 되었습니까?

해결책

I'm using code from 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

You'll need to set the variables to the specifics of your project obviously. These are more than likely the classes and methods you'll be wanting to use however. This should allow you to take your crystal reports viewer file and turn it into something opened by PDF

다른 팁

This works for me.

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top