PHPExcel lock cells

I’ve been using wonderful PHPExcel library for exporting my mysql data to excel via PHP and encountered a little setback trying to lock particular cells to prevent my client from editing values I’d need to process when uploading the file back to the system so I tried the most straightforward method I found in the official documentation but nothing seemed to work until I came across this solution:

$obj_Sheet->getProtection()->setPassword('pass_to_remove_protection');
$obj_Sheet->getProtection()->setSheet(true);
$obj_Sheet->getStyle('B2:J5')->getProtection()->setLocked(PHPExcel_Style_Protection::PROTECTION_UNPROTECTED);

First I set the password to remove protection (‘pass_to_remove_protection’) that anyone can use to remove protection (as long as they know the password), then I turn on sheet protection and finally set all cells in a┬árange from B2 to J5 to unprotected. This basically locked EVERYTHING on selected sheet and unlocked the fields I specified as unlocked.