Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel spreadsheet remains locked after viewing report

Status
Not open for further replies.

merceng

Programmer
Jul 28, 2005
3
GB
Hi all.

I have a problem with a report that uses Excel as a datasource.

I am using Crystal XI Professional, Delphi 7 and Excel 2002.

I have a Delphi application which uses the Crystal Reports viewer control to preview a report. The report displays OK, but when I close the form containing the control, I find that the Excel spreadsheet remains locked.

I am using the following code:

crReport := Application1.OpenReport(extractfilepath(forms.Application.ExeName) + 'Reports\Machine Scheduling.rpt',crOpenReportByTempCopy);
crReport.DiscardSavedData;

crReport.ParameterFields.GetItemByName('MachineCentre','').AddCurrentValue('CNC Turn') ;

CRViewer1.EnableExportButton := true;
CRViewer1.EnableGroupTree := false;
CRViewer1.ReportSource := crReport;
CRViewer1.ViewReport;

In the Form's OnClose event I have the following:

crReport._Release;
crReport := nil;

I've also tried adding:

Application1 := nil;

But this doesn't seem to make any difference!

I assume I'm missing a piece of code that will force Crystal to release the file?

Any help would be greatly appreciated.

Thanks in advance.

Dave
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top