enable editing for empty cell

Topics: Developer Forum, User Forum
Aug 2, 2010 at 7:40 PM

Hi, All

I am produce excel using protection. My goal is simple. User can not modify the cell pre-filled with values, but he can edit any cell without a pre-filled value.

I am using this code:


//lock cell with values

$sheet->setCellValue("A1", "Study");


//unlock cell without values

$sheet->getStyleByColumnAndRow($i, $j)->getProtection()->setLocked(PHPExcel_Style_Protection::PROTECTION_UNPROTECTED);

//output the excel

    $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');


However,  all the cells are protected. End user can not edit any cells.

Any suggestion?