I'm finally migrating my code from your old TXLSRead to TXLSReadWriteII5, and thus I'm using DirectRead=True. If my code throws an exception in OnReadCell, the TXLSReadWriteII5 component is left in a bad state. The next time the user tries to read a spreadsheet, they get an error: "OPC is allready open".
I believe I've implemented a fix, but I'd like you to review and confirm (and perhaps include in a subsequent release). The fix is to add a try finally, as follows:
Code: Select all
procedure TXLSReadXLSX.LoadFromStream(AZIPStream: TStream);
begin
FTotCells := 0;
FTotRows := 0;
// MJF 2014-01-20: Added try-finally to make sure that the OPC is closed
FManager.FileData.LoadFromStream(AZipStream);
try
ReadStyles;
ReadSST;
ReadConnections;
ReadWorkbook;
ReadSheets;
// ReadSheetsThread;
FManager.FileData.ReadUnusedData;
finally
FManager.FileData.OPC.Close;
end;
end;
Thanks,
Mark