使用PHPExcel保护Excel文件 [英] Protect the Excel file using PHPExcel

查看:235
本文介绍了使用PHPExcel保护Excel文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用PHPExcel创建受密码保护的Excel工作表,我知道如何使用

How can I create password protected excel sheet using PHPExcel, I know how to protect excel sheet using

$G=$objPHPExcel->setActiveSheetIndex(0);
$G->getProtection()->setSheet(true);

但是我没有任何链接可以知道如何仅设置密码来编辑保护,这意味着用户可以不用密码打开文件,但是不能从工作表中删除保护,任何人都可以从数据"菜单轻松地完成保护.欢迎提出建议.

But I am not getting any link how to set the password for editing protection only, means user can open the file without password but cannot remove the protection from sheet which can be easily done by any one from Data menu. Suggestions are welcomed.

推荐答案

仅适用于Excel2007 Writer:

For Excel2007 Writer only:

设置工作簿安全性:

$objPHPExcel->getSecurity()->setLockWindows(true);
$objPHPExcel->getSecurity()->setLockStructure(true);

$objPHPExcel->getSecurity()->setWorkbookPassword('secret');

设置工作表安全性:

$objPHPExcel->getActiveSheet()->getProtection()->setSheet(true);
$objPHPExcel->getActiveSheet()->getProtection()->setSort(true);
$objPHPExcel->getActiveSheet()->getProtection()->setInsertRows(true);
$objPHPExcel->getActiveSheet()->getProtection()->setFormatCells(true);

$objPHPExcel->getActiveSheet()->getProtection()->setPassword('password');

这篇关于使用PHPExcel保护Excel文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆