Worksheet password not being set

Topics: User Forum
Jul 31, 2012 at 6:02 PM

Hello,

I am new to setting passwords with PHPExcel. I am creating a multiple-worksheet spreadsheet. I set the password correctly on one.

But when I use the same code on another, the password is not being set.

The PHPExcel version is 1.7.6 and the PHP version is 5.4.4

Here is my code:

private function locksheet($obj){
    $obj->getActiveSheet()->getProtection()->setPassword('PHPExcel');
    $obj->getActiveSheet()->getProtection()->setSheet(true);
    $obj->getActiveSheet()->getProtection()->setSort(true);
    $obj->getActiveSheet()->getProtection()->setFormatCells(true); }

I pass $objPHPExcel to this method. Again, it works in one sheet but not another. And yes, I am setting setActiveSheetIndex between sheets.

In the second sheet, the cell-level security and validations work correctly after I manually set the password.

Any suggestions?

 

 

 

 

 

Apr 11, 2013 at 7:14 AM
Hi aberkowitz

I am new for PHPExcel. my requirement excel sheet protect using password.

could you please post me source code

Thanks,