解除保护

当工作表具有编辑保护时,可以使用本样式将特定行、列、单一单元格解除编辑保护,使其可以任意编辑。

函数原型

  1. unlocked();

示例

  1. $config = [
  2. 'path' => './'
  3. ];
  4. $fileObject = new \Vtiful\Kernel\Excel($config);
  5. $fileObject = $fileObject->fileName('tutorial.xlsx');
  6. $fileHandle = $fileObject->getHandle();
  7. // 创建解除保护样式
  8. $format = new \Vtiful\Kernel\Format($fileHandle);
  9. $unlockedStyle = $format->unlocked()->toResource();
  10. $filePath = $fileObject->header(['name', 'age'])
  11. ->data([
  12. ['wjx', 21]
  13. ])
  14. ->setRow('A2', 50, $unlockedStyle) // 将工作表中的第二行解除编辑保护
  15. ->protection() // 工作表添加编辑保护
  16. ->output();