Information générale
Titre:
Crystal to PDF in ASP.NET
I have successfully created a dynamic pdf using asp.net/crystal reports. I am building a new report in similar fashion and can't get past a problem. I can build the report using a dataset in Crystal Reports but when I try to export it to PDF, all I get is a black report. None of the dataset contents is showing up on my report.
Here is some code:
while db.dr.read
'fill my variables
ldrNewRow = pobjDS.Tables("PrintBatch").NewRow
ldrNewRow.ItemArray = myDataRows
pobjDS.Tables("PrintBatch").Rows.Add(ldrNewRow)
For z = 0 To 32
myDataRows(z) = Nothing
Next
End While 'END WHILE DB.DR.READ
'CREATE THE CRYSTAL REPORT THEN EXPORT TO PDF
Dim intUniqueNumber As Int32
intUniqueNumber = objFunctions.GetUniqueValue
Dim oRpt As New rptBatch()
' This is the Crystal Report file created at Design Time
oRpt.SetDataSource(pobjDS)
' Set the SetDataSource property of the Report to the Dataset
CrystalReportViewer1.ReportSource = oRpt
'Note : we are creating an instance of the strongly-typed Crystal Report file here.
Dim DiskOpts As CrystalDecisions.Shared.DiskFileDestinationOptions = New CrystalDecisions.Shared.DiskFileDestinationOptions()
Try
oRpt.ExportOptions.ExportDestinationType = CrystalDecisions.[Shared].ExportDestinationType.DiskFile
' You also have the option to export the report to other sources
' like Microsoft Exchange, MAPI, etc.
oRpt.ExportOptions.ExportFormatType = CrystalDecisions.[Shared].ExportFormatType.PortableDocFormat
'Here we are exporting the report to a .pdf format. You can
' also choose any of the other formats specified above.
DiskOpts.DiskFileName = "e:\inetpub\MedConnect\Print\docs\report" & Session("FileName") & ".pdf"
'E:\inetpub\MedConnect\Print\docs
'If you do not specify the exact path here (i.e. including
' the drive and Directory),
'then you would find your output file landing up in the
'c:\WinNT\System32 directory - atleast in case of a
' Windows 2000 System
oRpt.ExportOptions.DestinationOptions = DiskOpts
oRpt.Export()
strReport = "e:\inetpub\MedConnect\Print\docs\report" & Session("FileName")
'Clear previous objects from memory
Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/pdf"
Response.WriteFile(strReport & ".pdf")
Response.Expires = 0
Response.Flush()
Response.Close()
'System.IO.File.Delete(strReport & ".pdf")
objFunctions.SetViewedFlag(Session("FileName"))
Catch err As Exception
End Try
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement