Finding Spreadsheet Using Visual Controls lazarus / 49-FPSpreadsheet ---------------------------------------------------------------------- Rog · 2015-12-03 10:02 I'm new to Lazarus, having not used Delphi since version 7. For a first project, using Windows 10, Lazarus version 1.44 and FPSpreadsheet version 1.6, I have created a simple form that has a TSWorkbooksource and a TSWorksheetgrid on it, together with some other, standard, controls. My only problem is loading the spreadsheet. Generally the spreadsheet will be in the same folder as the application, so is easy to code, but there are occasions when it might not be or might be renamed. If I specify the file everything works ok, but if I try to add a file selection, using a TOpenDialog then everything goes crazy. It compiles ok, then goes into a debugging cycle that locks up the PC. Gets a debugging message that includes: "Could not send command to GDB" "The GDB process is no longer running" The only way to get out is to restart the PC. 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 procedure TForm1.FormCreate(Sender: TObject);var  s : string;begins := Application.Location+'\b1data.xlsx';if not fileexists(s) then {code between here and next comment is what causes problem}  begin  if OpenDialog1.execute then       s := OpenDialog1.filename     else     Application.terminate; {end of problem code}sWorkbookSource1.LoadFromSpreadsheetFile(s);  // This loads the file  Looking at the FPSpreadsheet tutorial it refers to the fileopen action, but I can't work out how to use it in the above context. Any help gratefully received! ---------------------------------------------------------------------- wp · 2015-12-03 10:39 There seems to be a missing "end" before the "sWorkbookSource1.LoadFromSpreadsheetFile(s)": 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 procedure TForm1.FormCreate(Sender: TObject);var  s : string;begin  s := Application.Location+'\b1data.xlsx';  if not fileexists(s) then {code between here and next comment is what causes problem}  begin    if OpenDialog1.execute then       s := OpenDialog1.filename    else       Application.terminate;  end;    // <---- missing {end of problem code}  sWorkbookSource1.LoadFromSpreadsheetFile(s);  // This loads the file  ...  // rest of your code in FormCreateend; But this does not explain what's wrong with the debugger. Can you strip down the issue into a compilable project which you upload here (only .lfm, .pas, .lpi, and .lpr files, packed into a single zip)? It could also be - I did not check - that the OnCreate event is too early for the WorkbookSource and the linked grid to be able to load a file. See what happens if you place your code (at least the LoadfromSpreadsheetFile) into another event executed later, OnShow or OnActivate. ---------------------------------------------------------------------- Rog · 2015-12-03 16:18 Thanks for reply. event I will try out moving the action from the onCreate event later, but I am going to have to reinstall Lazarus, because it will not start now - just goes into a loading loop. I have a question before I do, and it is to do with adding the FPSpreadsheet packages. Do I need to add all 3 packages (laz_fpspreadsheet, laz_fpspreadsheet_visual and laz_fpspreadsheetexport_visual) that are in the downloaded exe, or, as I will probably only be relying on the visual packages, the latter two? Many thanks Roger ---------------------------------------------------------------------- wp · 2015-12-03 17:12 laz_fpspreadsheet is the heart of the library, it is essentially needed. But it is a runtime package, you only have to compile it. Since you want to use the grid you'll need the laz_fpspreadsheet_visual as well. This is to be installed. During its installation it will automatically take care of the laz_fpspreadsheet. The laz_fpspreadsheetexport_visual, finally, is not needed normally, only if you want to export workbooks to/from databases and if you want the visual controls for this purpose. So, to summarize, the only thing you'll have to touch is the laz_fpspreadsheet_visual package: load it, compile it and click "use"/"install". After you reinstalled everything load, compile and run at least some of the visual demos in the examples folder of the fpspreadsheet installation. The fpsctrls demo is my "work horse", it is definitely working, but the others should work as well. If you can run this demo then you'll have a good feeling that everything is correct. ---------------------------------------------------------------------- Rog · 2015-12-04 16:37 Hi, Having all sorts of problems with it now. I had to restart in safe mode to remove Lazarus. Downloaded the Lazarus and FPSpreadsheet files to ensure I have the latest versions Reinstalled Lazurus(Win 64bit), and then extracted FPS from the zip file. Started, exited and restarted Lazarus ok. Compiled laz_fpspreadsheet. (got a few warnings but reported as compiled ok) Checked the package links dialog, and it was there, although showing invalid. Closed Lazarus, and then tried re-starting. Hangs on the splash screen. Windows allows me to close (hide?) the splashscreen, but won't allow the uninstaller to delete either Lazarus.exe or laz_fpspreadsheet as both in use by system, although I can't find them using task manager. Restarting Windows still reports them as being in use by System. It's only restarting in safe mode that allows me to delete them. If I don't try undeleting and just try restarting Windows, and then clicking the Lazurus shortcut just causes the waiting cursor to appear. Any ideas? Thanks ---------------------------------------------------------------------- wp · 2015-12-04 17:06 Quote from: Rog on December 04, 2015, 05:37:02 pmDownloaded the Lazarus and FPSpreadsheet files to ensure I have the latest versionsWhich ones? Stable or trunk? At the moment, laz stable is version 1.4.4 with fpc 2.6.4, and fpspreadsheet stable is version 1.6 Quote from: Rog on December 04, 2015, 05:37:02 pmReinstalled Lazurus(Win 64bit)Lararus 32-bit on Win64bit or Lazarus 64-bit on Win 64-bit? People usually work with Laz 32-bit because of better debugger integration. I rarely test fpspreadsheet on 64-bit Lazarus. So please use the 32-bit version, you can still create a 64-bit version by means of cross-compilation. Where did you install Lazarus? According to the docs some tools needed do not like a space in the folder name, i.e. "C:\Program files" is not good. I usually accept the default "c:\Lazarus", another local drive is fine as well. No idea about issues if Laz is installed to a network drive. Quote from: Rog on December 04, 2015, 05:37:02 pmChecked the package links dialog, and it was there, although showing invalid. I've never seen this... Check the box at the left and delete all fps packages, or better: rename your Lazarus configuration folder (by default, it is in "c:\users\\AppData\Local" and called "lazarus", or, in case of a secondary installation its folder is specified by means of the --pcp or --primary-config-path parameter at the commandline or in the file "lazarus.cfg"). When you restart Lazarus new clean default settings are created. Re-install fps. If everything works re-install your other non-default components afterwards one by one and see if there is some package which causes trouble again. If Lazarus hangs on the splash screen use the Windows task manager to kill the process. Don't use page "Applications" of the task manager, use page "Processes" instead. I could always kill a hanging Lazarus this way. If Lazarus hangs don't restart another instance, always clean up processes in the task manager in case of such problems. Quote from: Rog on December 04, 2015, 05:37:02 pmRestarting Windows still reports them as being in use by System.Did you really shut-down? Win10 - I think - only puts itself into the hiberation file in order to mimik a faster startup. ---------------------------------------------------------------------- wp · 2015-12-06 09:48 There's another thread describing similar symptoms with Win10: http:// forum.lazarus.freepascal.org/index.php/topic,30633.msg195078.html#msg1 95078. Here the antivirus program was found to be the culprit. ---------------------------------------------------------------------- Rog · 2015-12-07 09:26 Quote from: wp on December 06, 2015, 10:48:04 amThere's another thread describing similar symptoms with Win10: http://forum.lazarus.freepasca l.org/index.php/topic,30633.msg195078.html#msg195078. Here the antivirus program was found to be the culprit. That's it! thanks a lot. Same problem as in that thread - Avast deciding it was going to ignore my excepted files. Re-entered them and it is running ok. I still have a problem with the standard Open Dialog, but I'll post about it in the correct thread. Once again - many thanks