[fpspreadsheet] Read from ods with password lazarus / 49-FPSpreadsheet ---------------------------------------------------------------------- bonmario · 2023-07-23 05:07 Hi, sorry for my bad english ... When i must read from a file Ods, i use this code: 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 MyWorkbook.ReadFromFile(NomeDocSaleranoTmp, sfOpenDocument); If a file is protected from a password, how can i read from this? Thanks, Mario ---------------------------------------------------------------------- wp · 2023-07-23 11:51 Sorry, password-protection is supported, in a very elemental form, only for Excel XLSX. ---------------------------------------------------------------------- bonmario · 2023-07-23 16:09 Don't worry, it's no problem. Thanks anyway for the excellent work done with this Package Hi Mario ---------------------------------------------------------------------- wp · 2023-07-31 10:20 OK - here is a reader for encrypted ods files. Not heavily tested, but it works at least with my test file. Please note that it depends on the Abbrevia (because the FPC zipper cannot extract the encrypted xml subfiles) and DCPCrypt (because FPC does not provide AES decryption) libraries. You can find both libraries in the OPM. No need to install, just download and open the lpk package file so that the IDE knows where they are. Afterwards you can compile the demo program in the attachment. ---------------------------------------------------------------------- rvk · 2023-07-31 11:36 Quote from: wp on July 31, 2023, 12:20:39 pmPlease note that it depends on  (...) and DCPCrypt (because FPC does not provide AES decryption) libraries. If you don't want the dependency with DCCrypt, I think this could, theoretically, also be done with calls to openssl (aes-256-cbc)  (Not sure if FPC exposes all the necessary calls.) ---------------------------------------------------------------------- wp · 2023-07-31 18:00 Found Wolfgang Ehrhardt's crypto library (https://github.com/chadilukito/www.wolfgang- ehrhardt.de/tree/master/src/crypto) which can be integrated into fpspreadsheet-crypto more easily. Here is the same sample project, now without dependence on DCPcrypt. ---------------------------------------------------------------------- rvk · 2023-08-01 09:11 Quote from: wp on July 31, 2023, 08:00:16 pmFound Wolfgang Ehrhardt's crypto library (https://github.com/chadilukito/www.wolfgang- ehrhardt.de/tree/master/src/crypto) which can be integrated into fpspreadsheet-crypto more easily. Here is the same sample project, now without dependence on DCPcrypt. It wasn't the dependency to DCPcrypt perse, but if it was possible to use openssl (which would be installed by default everywhere in FPC) that would have been much easier. But using the openssl functions currently present in FPC to decrypt AES-256-CBC isn't as easy as it looks (but should be possible). (An example in Delphi https://stackoverflow.com/a/9733823/1037511 but the key creation is somewhat different there) But for now including Wolfgang's library should be sufficient for use case of TS (and others). ---------------------------------------------------------------------- wp · 2023-08-01 09:17 Quote from: rvk on August 01, 2023, 11:11:06 ambut if it was possible to use openssl (which would be installed by default everywhere in FPC) that would have been much easier. But still the openssl dlls would have to be available at runtime. I would like to keep fpspreadsheet clean of such requirements. ---------------------------------------------------------------------- rvk · 2023-08-01 09:42 Quote from: wp on August 01, 2023, 11:17:46 amBut still the openssl dlls would have to be available at runtime. I would like to keep fpspreadsheet clean of such requirements. Ah, Ok. No problem. In that case a 3dparty folder in fpspreadsheet is preferable above including the dependency to openssl dlls. (I guess openssl dll's aren't as standard as I thought  ) ---------------------------------------------------------------------- wp · 2023-08-06 11:04 Reading a password-protected ods workbook is now included in the svn version of fpspreadsheet (package laz_fpspreadsheet_crypto.lpk) https://wiki.lazarus.freepascal.org/FPSpreadsheet#Workbook_protection - last paragraph and code. ---------------------------------------------------------------------- bonmario · 2023-08-13 08:56 Quote from: wp on August 06, 2023, 01:04:22 pmReading a password- protected ods workbook is now included in the svn version of fpspreadsheet (package laz_fpspreadsheet_crypto.lpk) https://wiki.lazarus.freepascal.org/FPSpreadsheet#Workbook_protection - last paragraph and code. HI, sorry for the delay, but I didn't realize there were new replies. I've seen them now, and I've tried the modifications: you've done a splendid job. Thanks, Mario