The report is really big, it needs to read 80,000 records, & generate 4500 pages,
It takes 2-3 minutes to export the report, & I need to show the progress for the user while it’s exporting,
The best would be if I can show a progress bar with the percentage & saying “Exporting page X of X” (When you run a report in crystal report designer, there is something like this),
Based on what I have searched it sounds like there is no way to do this with there API,, But without this it’s almost useless, So I’m wondering if there may be some workaround to accomplish this;
Here is my code:
קאוד: וועל אויס אלע
Dim WithEvents rpt As New CrystalDecisions.CrystalReports.Engine.ReportDocument
rpt.Load("\\fs\users\SomeUser\Temp\report1.rpt")
'This line takes 2-3 minutes, I need to provide status to the user in this time
rpt.ExportToDisk(ExportFormatType.PortableDocFormat, "C:\Temp\TestReport.pdf")
I have tried to run it in a different thread, & run a timer in the main thread that should constantly check the page count, but the application gets frozen & it doesn’t return anything (probably it’s not made for multi-threading)
קאוד: וועל אויס אלע
Public Class Form1
Dim WithEvents Timer1 As New Timer
Dim WithEvents BG1 As New System.ComponentModel.BackgroundWorker
Dim WithEvents rpt As New CrystalDecisions.CrystalReports.Engine.ReportDocument
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
rpt.Load("\\fs\users\SomeUser\Temp\report1.rpt")
Timer1.Start()
BG1.RunWorkerAsync()
End Sub
Private Sub BG1_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles BG1.DoWork
'This line takes 2-3 minutes, I need to provide status to the user in this time
rpt.ExportToDisk(ExportFormatType.PortableDocFormat, "C:\Temp\TestReport.pdf")
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Try
TextBox1.Text = Now & ": " & rpt.ReportRequestStatus.NumberOfRecordRead & " - " & rpt.ReportRequestStatus.NumberOfPages
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
End Class