Stream read error lazarus / 49-FPSpreadsheet ---------------------------------------------------------------------- totya · 2017-01-24 20:37 Hi! Today in workplace I download files via ftp... but this isn't important... shorty, if the opened excel file is invalid, exactly the file length is 0 byte, I get this exception: Stream Read Error (with Spready too). Can I get this exception via standard way, for example On E : EInvalidFile do etc... ? Thanks! ---------------------------------------------------------------------- wp · 2017-01-24 20:56 Something like this? Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program read_empty_file; {$mode objfpc}{$H+} uses  SysUtils, fpspreadsheet, fpstypes, xlsBiff8; const  fn = 'zero_byte_file.xls';var  book: TsWorkbook;begin  book := TsWorkbook.Create;  try    try      book.ReadFromFile(fn, sfExcel8);    except      on E:Exception do WriteLn('Cannot read file "' + fn + '": ' + E.Message);    end;  finally    book.Free;  end;   ReadLn;end. Note that even if the error is caught by means of a try-except block one or more exceptions are raised if the program runs inside the IDE. This does not occur if the program is started outside of the IDE: ---------------------------------------------------------------------- totya · 2017-01-24 21:25 Hi! I think you misunderstand my first post, certainly I can catch open file exception via try-except, I thought I can get more specific error types for example EInvalidFile, EZeroByteFile etc... But thanks for the answer! ---------------------------------------------------------------------- wp · 2017-01-24 21:37 Not at the moment, fpspreadsheet does not define its own exception types. If you think that 0-byte files are a particular problem for your application, then you should check the file size before passing the filename to fpspreadsheet. ---------------------------------------------------------------------- totya · 2017-01-24 21:43 Yes, I tought it, filesize check is not a big problem...