简体   繁体   English

使用phpExcel锁定/使只读一系列Excel单元格

[英]Locking/make read only a range of Excel Cells using phpExcel

How can one lock or make specific cell or range of excel cells read only using phpExcel or just with php after exporting data to those cells say 如何在将数据导出到这些单元格之后锁定或使特定单元格或范围的excel单元格仅使用phpExcel读取或仅使用php读取

from A17:f45? 从A17:f45?

See section 4.6.26 of the Developer Documentation 请参阅开发人员文档的4.6.26节

$objPHPExcel->getActiveSheet()
    ->getStyle('A17:F45')
    ->getProtection()
    ->setLocked(
        PHPExcel_Style_Protection::PROTECTION_PROTECTED
    );

before, set protected property for the sheet 之前,为工作表设置protected属性

$objPHPExcel->getActiveSheet()->getProtection()->setSheet(true);    // Needs to be set to true in order to

$objPHPExcel->getActiveSheet()
->getStyle('A17:F45')
->getProtection()
->setLocked(
    PHPExcel_Style_Protection::PROTECTION_PROTECTED
);

regards 问候

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM