bobschroeder
Programmer
Our current application uses code like in he excerpt below and is slow.
It is using the CrystalDecisions.CrystalReports.EngineReportDocument.Export
Method (from Version=9.2.3300.0) to write a temporary file and then write the file to the asp.net page. (I didn't write it but I think it was modelled after a sample from gotdotnet).
Anyways the .export method takes over 3 minutes to run in code, while if opening the crystal report file, refreshing the report data, and exporting to pdf takes less than 30 seconds.
Is there a better way of doing this? (The exporttostream method isn't available in 9.2.3300.0)
Thanks....
****CODE EXCERPT
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
.
.
.
Public Sub ExecuteReport()
.
.
.
'## ste the report name for logging
strReportName = objReportDetails.strName
Dim exportFilePath As String = "c:\Temp\" & Session.SessionID.ToString & ".pdf"
If System.IO.File.Exists(exportFilePath) Then
System.IO.File.Delete(exportFilePath)
End If
''Create an instance of the untyped report object
crReportDocument = New ReportDocument()
''Load the report from disk
crReportDocument.Load("c:\reports\" & objReportDetails.strFileName)
.
.
.
''Set the options for saving the exported file to disk
crDiskFileDestinationOptions = New DiskFileDestinationOptions()
crDiskFileDestinationOptions.DiskFileName = exportFilePath
''Set the exporting information
crExportOptions = crReportDocument.ExportOptions
With crExportOptions
.DestinationOptions = crDiskFileDestinationOptions
.ExportDestinationType = ExportDestinationType.DiskFile
.ExportFormatType = ExportFormatType.PortableDocFormat
End With
''Export the report
crReportDocument.Export()
'#################
'## write the pdf file to the browser
Response.ClearContent()
Response.ClearHeaders()
Response.Expires = 0
Response.ContentType = "application/pdf"
Response.WriteFile(exportFilePath)
Response.Flush()
Response.Close()
If System.IO.File.Exists(exportFilePath) Then
System.IO.File.Delete(exportFilePath)
End If
crReportDocument.Close()
crReportDocument.Dispose()
End Sub
It is using the CrystalDecisions.CrystalReports.EngineReportDocument.Export
Method (from Version=9.2.3300.0) to write a temporary file and then write the file to the asp.net page. (I didn't write it but I think it was modelled after a sample from gotdotnet).
Anyways the .export method takes over 3 minutes to run in code, while if opening the crystal report file, refreshing the report data, and exporting to pdf takes less than 30 seconds.
Is there a better way of doing this? (The exporttostream method isn't available in 9.2.3300.0)
Thanks....
****CODE EXCERPT
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
.
.
.
Public Sub ExecuteReport()
.
.
.
'## ste the report name for logging
strReportName = objReportDetails.strName
Dim exportFilePath As String = "c:\Temp\" & Session.SessionID.ToString & ".pdf"
If System.IO.File.Exists(exportFilePath) Then
System.IO.File.Delete(exportFilePath)
End If
''Create an instance of the untyped report object
crReportDocument = New ReportDocument()
''Load the report from disk
crReportDocument.Load("c:\reports\" & objReportDetails.strFileName)
.
.
.
''Set the options for saving the exported file to disk
crDiskFileDestinationOptions = New DiskFileDestinationOptions()
crDiskFileDestinationOptions.DiskFileName = exportFilePath
''Set the exporting information
crExportOptions = crReportDocument.ExportOptions
With crExportOptions
.DestinationOptions = crDiskFileDestinationOptions
.ExportDestinationType = ExportDestinationType.DiskFile
.ExportFormatType = ExportFormatType.PortableDocFormat
End With
''Export the report
crReportDocument.Export()
'#################
'## write the pdf file to the browser
Response.ClearContent()
Response.ClearHeaders()
Response.Expires = 0
Response.ContentType = "application/pdf"
Response.WriteFile(exportFilePath)
Response.Flush()
Response.Close()
If System.IO.File.Exists(exportFilePath) Then
System.IO.File.Delete(exportFilePath)
End If
crReportDocument.Close()
crReportDocument.Dispose()
End Sub