Skip to content
This repository was archived by the owner on Jan 2, 2019. It is now read-only.
This repository was archived by the owner on Jan 2, 2019. It is now read-only.

Worksheet Protection not working in Open Offfice #480

@versionii

Description

@versionii

I'm building a workbook with a protected worksheet in it.

When I open the file in OpenOffice 4.0.1, the sheet appears protected (it prompts with a dialog box that reads, "Protected Cells can not be modified", if I try to edit a cell).

However, if I then select: Tools > Protect Document > Sheet - it just turns off the worksheet protection without prompting for the password.

FYI: The same file when opened with MS Office Excel 2007 works as expected.

Below is the code I am using:

////////////////////////////////////////////////////////////////////////
//LOCK SHEET
$objPHPExcel->setActiveSheetIndex(1);
$objPHPExcel->getActiveSheet()->getProtection()->setSheet(true);
$objPHPExcel->getActiveSheet()->getProtection()->setSort(true);
$objPHPExcel->getActiveSheet()->getProtection()->setInsertRows(true);
$objPHPExcel->getActiveSheet()->getProtection()->setFormatCells(true);
$objPHPExcel->getActiveSheet()->getProtection()->setPassword('password');

// Set active sheet index to the first sheet on open
$objPHPExcel->setActiveSheetIndex(0);

//output to browser
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="participants.xlsx"');
header('Cache-Control: max-age=0');

$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save('php://output');

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions