PHPOffice / PHPExcel

ARCHIVED
Other
11.46k stars 4.19k forks source link

Worksheet Protection not working in Open Offfice #480

Open versionii opened 9 years ago

versionii commented 9 years ago

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');

versionii commented 9 years ago

FYI: This same issue occurs with the protection example in the PhpExcel package. You can simply turn off the protection in Open Office without a password.

tasso85 commented 9 years ago

This just happened to me also using Microsoft Office Excel 2007

jwegner commented 9 years ago

Same issue here with Open Office 3.2 and Excel2007. Excel5 just works fine. I use PHPExcel 1.8.0.