Cell protection locking entire sheet

Jul 5, 2011 at 8:49 PM

Hi -

  I'm running into a problem that I have yet to figure out a solution for. I'm creating an XLSX with a number of different sheets etc. and all works well in that aspect - the problem comes up when I try to lock down certain cells. The idea is that there is one header row, which I want to keep locked. The rows underneath are editable by the end user.
I have tried several different versions / approaches of this idea, but every time I apply the security to the cells, the entire sheet gets locked top to bottom.
Here is my code (largely taken from the samples found online):

    $objPHPExcel->getActiveSheet()->getStyle('A1:' . getNameFromNumber($subcounter - 1) . '1')->getProtection()->setLocked(PHPExcel_Style_Protection::PROTECTION_PROTECTED);

the "getNameFromNumber" function returns an Excel alphabetical column name based on the number I pass in (easier that way to keep a counter). I'm trying to lock the first row for however many columns there are in the sheet (through whatever the counter-1 is).

Any insight would be MUCH appreciated!

- C