getActiveSheet(); $sheet->getCell('A1')->setValue(1); $protection = $sheet->getProtection(); $protection->setAlgorithm($algorithm); $protection->setPassword($password); $protection->setSheet(true); $reloadedSpreadsheet = $this->writeAndReload($spreadsheet, $format); $resheet = $reloadedSpreadsheet->getActiveSheet(); $reprot = $resheet->getProtection(); $repassword = $reprot->getPassword(); $hash = ''; if ($supported) { $readAlgorithm = $reprot->getAlgorithm(); self::assertSame($algorithm, $readAlgorithm); $salt = $reprot->getSalt(); $spin = $reprot->getSpinCount(); $hash = PasswordHasher::hashPassword($password, $readAlgorithm, $salt, $spin); } self::assertSame($repassword, $hash); $spreadsheet->disconnectWorksheets(); $reloadedSpreadsheet->disconnectWorksheets(); } public function providerPasswords(): array { return [ 'Xls basic algorithm' => ['Xls', ''], 'Xls cannot use SHA512' => ['Xls', 'SHA-512', false], 'Xlsx basic algorithm' => ['Xlsx', ''], 'Xlsx can use SHA512' => ['Xlsx', 'SHA-512'], ]; } }