Hi!
I'm creating an application where the user can select to export the crystal report without open it. The user will not see the report but it should run so I can have the data to export. I'm having problems when I try to close the report viewer form. I get the message: "InvalidOperationException was unhandled. Value Close() cannot be called while doing CreateHandle()". Does anyone know how should I close this report without errors?
Thanks!!!!
rptDoc1.ExportToDisk(ExportFormatType.ExcelRecord, filePath);
crRV1.ReportSource = rptDoc1;
if (MessageBox.Show("Report " + filePath + " exported successfully.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information) == DialogResult.OK)
{
this.Hide();
this.Close(); // I get the message here: InvalidOperationException was unhandled. Value Close() cannot be called while doing CreateHandle().
this.Dispose();
}
Mahesh ChandPosted May 13, 2008, 10:06 AM
Here is an article on how to export a Crystal Report to Excel, PDF and Doc formats programmatically:
http://www.c-sharpcorner.com/UploadFile/mahesh/ExportCRtoPDF10062006161918PM/ExportCRtoPDF.aspx
Patricia ProbstPosted May 13, 2008, 8:38 AM
Yes, I am... But I don't see another way to do it!
This form is only used to run the reports. It's called from another forms and runs crystal reports on it. When I need to only to export the reports, the form shouldn't be showed to the user but still have to run to get the data and export it to excel.
Do you have any sugestions?
Dipal ChoksiPosted May 13, 2008, 12:17 AM
Hi,
Are you calling this code in the Load event handler? That could be the problem...
I am just trying to guess your issue from the information you have given and the error message..