xls reader lazarus / 43-Android ---------------------------------------------------------------------- xinyiman · 2023-04-22 22:28 Hello, is there an example to understand how to read an excel file with LAMW? ---------------------------------------------------------------------- KodeZwerg · 2023-04-22 23:40 You can take a look into the FPSpreadsheet package but not ask me about how far it is compatible to your requirement, just test it and let us know ---------------------------------------------------------------------- xinyiman · 2023-05-20 17:27 Quote from: KodeZwerg on April 23, 2023, 01:40:44 amYou can take a look into the FPSpreadsheet package but not ask me about how far it is compatible to your requirement, just test it and let us know  I was unable to use the component on android. ---------------------------------------------------------------------- maurobio · 2023-05-21 11:39 Hi, @xinyiman! What exactly are the problems you have found when attempting to use the fpspreadsheet component on Android? I have been a more-or-less frequent user of this component for Linux/Windows applications and its developer, @wp, has been hugely helpful. Maybe he can be of help in this matter too? I am also interested in reading xls/xlsx files on Android apps. Best wishes, ---------------------------------------------------------------------- xinyiman · 2023-05-22 06:45 The problem is that it carries gtk dependencies with it. Finally, for my project I decided to switch from excel to csv. So I worked around the problem and moved on. ---------------------------------------------------------------------- maurobio · 2023-05-22 21:35 Hi, @xinyiman! I do understand. As the fpspreadsheet library also includes non-visual components which offer simple functions for reading/writing xls/xlsx/ods files, I thought that it could be used on Android apps. In fact, I have not took time to do some tests. That said, I am also inclined to use csv files in my app, as they are simpler to read and maintain. With best regards, ---------------------------------------------------------------------- wp · 2023-05-22 22:29 The basic fpspreadsheet package (laz_fpspreadsheet) does not depend on any widgetset. It should be possible to read a spreadsheet file on Android (although I never tried): 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 uses  fpspreadsheet, fpstypes, xlsbiff8, xlsxOOXML;var  workbook: TsWorkbook;  worksheet: TsWorksheet;begin  workbook := TsWorkbook.Create;  try    workbook.ReadFromFile(filename);    worksheet := workbook.GetWorksheetByIndex(0);    // do something with the worksheet, e.g.     ShowMessage('Cell A1 = ' + worksheet.ReadAsText(0, 0));  finally    workbook.Free;  end;end; ---------------------------------------------------------------------- maurobio · 2023-05-22 22:36 Hi, @wp! I will test it in Android as soon as possible. I would like to be able to read a spreadsheet using fpspreadsheet and then present the data in a jGridView on my app. With warmest regards, ---------------------------------------------------------------------- maurobio · 2023-05-23 11:45 Hi, @wp! I just started testing the use of the fpspreadsheet library in an Android application. So far, my tests have not been successful. I get a compilation error in function StrToAlgorithm in fpsCrypto unit. So I could not proceeed. My demo project is attached. Hope this helps. With warmest regards, ---------------------------------------------------------------------- wp · 2023-05-23 12:24 Normally you don't need the crypo package. It's only for reading encrypted xls files. ---------------------------------------------------------------------- maurobio · 2023-05-23 12:29 Hi, @wp! I am not calling any function in this package (fpsCrypto), it is not even in the list of units in my app. Best regards, ---------------------------------------------------------------------- wp · 2023-05-23 14:07 Do install fpspreadsheet via OPM? Open the FPSpreadsheet node in OPM and check only "laz_fpspreadsheet.lpk". Click install. This way only the basic spreadsheet functionality is compiled. ---------------------------------------------------------------------- maurobio · 2023-05-23 14:23 Hi, @wp! Yes, I installed it via OPM, but the previouly reported compilation error persists. Notice that such error does not appear in an identical demo I created for Windows/Linux, it is displayed only when attempting to compile with LAMW. Best regards, ---------------------------------------------------------------------- rvk · 2023-05-23 14:59 Quote from: wp on May 23, 2023, 02:24:22 pmNormally you don't need the crypo package. It's only for reading encrypted xls files. Even with the basic "laz_fpspreadsheet.lpk" there is a fpsCrypto.pas in source/common. It is in the uses of laz_fpspreadsheet.pas so that's a problem then. It's also in the uses of fpopendocument.pas, xlsooxml.pas and fpspreadsheetctrls (which also comes with the basic install). ---------------------------------------------------------------------- wp · 2023-05-23 15:27 I see. But this one is harmless. StrToAlgorithm is just a conversion of a string to an enumerated variable. What exactly is the error message? Is your IDE set up such the "case of strings" is not allowed? I see that the OPM version does not have the compiler mode directive in the header of fpscrypto, unlike the svn version on CCR where I had added it some time ago. Well - this could be the reason... Add the line 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 {$mode objfpc}{$H+}to the top of the unit fpscrypto, and try again. ---------------------------------------------------------------------- maurobio · 2023-05-23 18:23 Hi, @wp! The error message is shown in the attached image. This seems to be releated do LAMW - I have no compiler errors with fpspreadsheet in either Windows or Linux. Hope this helps. With best wishes, ---------------------------------------------------------------------- jmpessoa · 2023-05-23 19:40 QuoteThis seems to be releated do LAMW... No! See previous message from  @wp ---------------------------------------------------------------------- maurobio · 2023-05-23 19:56 Hi, @jmpessoa! So, for some strange reason, the problem only appears in LAWM, because I have been using the fpspreadsheet library for years under Windows/Linux and have never had this problem before. In fact, an identical demo using FCL compiles and runs OK under Windows/Linux. Anyway, I gave up! Best regards, ---------------------------------------------------------------------- rvk · 2023-05-23 20:05 Quote from: maurobio on May 23, 2023, 09:56:25 pmIn fact, an identical demo using FCL compiles and runs OK under Windows/Linux. Did you already try to put {$mode objfpc}{$H+} at the top of that file as wp suggested? (It might be default in Win/Linux and not for Android) ---------------------------------------------------------------------- maurobio · 2023-05-23 21:25 Hi, @rvk! I didn't try it. I gave up using fpspreadsheet on Android at this time. The jTableLayout component is adequate to my needs and it seems nicely tailored to use CSV files anyway. Best regards,