BOF record not found when read excel file to fpspreadsheet lazarus / 49-FPSpreadsheet ---------------------------------------------------------------------- mrkwlee · 2018-07-04 08:54 My system is  win 10, Lazarus 1.8.4, An excel file is read and displayed normally but an error message "BOF record not found " is shown. Can anyone please tell me why? The follow is my code: with OpenDialog1 do   if Execute then   begin     sWorkBookSource1.FileName:=FileName;     sWorkSheetGrid1.Enabled:=True;     Screen.Cursor := crHourglass;     try       workbook := TsWorkbook.Create;       try         Workbook.Options := Workbook.Options + [boReadFormulas, boAutoCalc];         Workbook.ReadFromFile(DataFileName, sfExcel2);       finally         Workbook.Free;       end;     finally       Screen.Cursor := crDefault;     end;   end; ---------------------------------------------------------------------- Handoko · 2018-07-04 09:09 Your code worked on my test if I remove sfExcel2. Are you sure you really need it? Have you tried to run the code without it? 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 Workbook.ReadFromFile(OpenDialog1.FileName); Read more: http://wiki.freepascal.org/FPSpreadsheet#Workbook ---------------------------------------------------------------------- mrkwlee · 2018-07-04 09:13 Thanks for your prompt reply. I have tried without sfExcel2 but I still got the same error. ---------------------------------------------------------------------- Handoko · 2018-07-04 09:21 Can you send me the sample excel file, which can cause the error for me to test? ---------------------------------------------------------------------- wp · 2018-07-04 17:23 "BOF record not found" indicates that the file which you are trying to load is not a binary Excel file: neither BIFF2, nor BIFF5 nor BIFF8 (all these must have a BOF = Begin-Of-File record) What are you trying to achieve? Your code is very confusing: sWorkBookSource1.FileName:=FileName; loads the file of the OpenDialog into the visual FPSpreadsheet controls.But then you create another workbook whichs reads the loaded file a second time assuming that it is the ancient xls-BIFF2 format (sfExcel2), and destroy the workbook immediately afterwards. Why do you do this? ---------------------------------------------------------------------- mrkwlee · 2018-07-05 07:30 Dear Handoko It works fine when sfExcel2 removed again. I think I have missed some unkown things. Thank you. ---------------------------------------------------------------------- Handoko · 2018-07-05 17:26 Good to hear it works. But, you should not be happy too early. When your not working code becomes working correctly without you fixing it, it usually means there is a 'hidden' bug. Something bad can happen in the future. The most important thing about bug fixing is you must know exactly what you've done that makes the code to work correctly. ---------------------------------------------------------------------- mrkwlee · 2018-07-06 02:18 Will test it for more situations.Thx