Read ods with password? lazarus / 49-FPSpreadsheet ---------------------------------------------------------------------- bonmario · 2022-01-17 15:43 Hi, with this code, i can read a file ods without password: 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:=TsWorkbook.Create;  try    MyWorkbook.ReadFromFile('PwdNo.ods', sfOpenDocument);     MyWorksheet:=MyWorkbook.GetFirstWorksheet;    Memo1.Lines.Add('File without password: Col = ' +                    IntToStr(MyWorksheet.GetLastColIndex(False)) +                    ' - Row = ' +                    IntToStr(MyWorksheet.GetLastRowIndex(False)));  finally    FreeAndNil(MyWorkbook);  end;  Now, the same file have been protected with password. I've tried with the code avove, but it fails: 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:=TsWorkbook.Create;  try    MyWorkbook.ReadFromFile('PwdYes_123456.ods', '123456'{, sfOpenDocument});     MyWorksheet:=MyWorkbook.GetFirstWorksheet;    Memo1.Lines.Add('File with password: Col = ' +                    IntToStr(MyWorksheet.GetLastColIndex(False)) +                    ' - Row = ' +                    IntToStr(MyWorksheet.GetLastRowIndex(False)));  finally    FreeAndNil(MyWorkbook);  end;  Someone can help me? Thanks, Mario ---------------------------------------------------------------------- wp · 2022-01-17 16:47 fpspreadsheet does not support encrypted files. ---------------------------------------------------------------------- rvk · 2022-01-17 17:05 You would need to unzip the content of the ods yourself (not protected) and look in the META-INF/manifest.xml. It will show how the files are encrypted (probably aes256-cbc). The initialisation-vector (IV) is also in there. With that you could try to decrypt all the files mentioned in that manifest.xml  (a recent post here shows some code to decrypt AES-256-CBC with TDCP_rijndael). After that you can rezip the contents back to an unprotected ods-file and read it with fpspreadsheet. (Don't forget to remove the encryption-data parts in the manifest.xml) Maybe you also need to do something (PBKDF2) with the password. See https://askubuntu.com/a/223183/926892 for more details. ---------------------------------------------------------------------- bonmario · 2022-01-18 07:36 Ok, thanks