When i click a button to open a excel, and then click the cancel button in the file searching dialog. It would run an error "raised exception class EFOpenError with message 'Cannot open file'. 'system can not find the path'". I found that the error was in "function TXLSStream.OpenFileStreamRead" in the unit XLSStream4. I have inserted try and except sentense to it, but it still run the same error. So could any experts help me to solve this problem. Thank you very much.
function TXLSStream.OpenFileStreamRead(const Filename: string): TExcelVersion;
var
Header: TBIFFHeader;
begin
//try
Result := xvNone; //the error existed
CloseStorage;
FStream := TFileStream.Create(Filename,fmOpenRead);
FStreamSize := FStream.Size;
FStream.Read(Header,SizeOf(TBIFFHeader));
if (Header.RecID and $FF) = BIFFRECID_BOF then begin
case (Header.RecID and $FF00) of
$0000: Result := xvExcel21;
$0200: Result := xvExcel30;
$0400: Result := xvExcel40;
end;
end;
FStream.Seek(0,soFromBeginning);
//except
//Exit;
//end;
end;
Bug in function TXLSStream.OpenFileStreamRead
-
- Posts: 3
- Joined: Wed Apr 25, 2012 12:04 pm
Re: Bug in function TXLSStream.OpenFileStreamRead
Hello
I don't understand. You click a cancel button and after that you call OpenFileStreamRead and it generates an exception (because you called it with an empty string?). What do you excpect shall happend?
If you call OpenFileStreamRead with an invalid filename there will be an exception.
I don't understand. You click a cancel button and after that you call OpenFileStreamRead and it generates an exception (because you called it with an empty string?). What do you excpect shall happend?
If you call OpenFileStreamRead with an invalid filename there will be an exception.
Lars Arvidsson, Axolot Data