3
Answers

Export Crystal Report to excel

Patricia Probst

Patricia Probst

16y
5.9k
1

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();

}

Answers (3)