我可以创建具有密码保护的Excel文件 [英] Can I create Excel file with password protection

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

问题描述

可以用php创建保存密码保护的Excel文件吗?我找到了很多类和方法,没有发现
谢谢你

解决方案

你可以使用优秀)PHPExcel为此。要锁定整个工作簿:

  $ reader = new PHPExcel_Reader_Excel2007; 
$ workbook = $ reader-> load(document.xlsx);
$ workbook-> getSecurity() - > setWorkbookPassword(你的密码);

或锁定工作表:

  $ reader = new PHPExcel_Reader_Excel2007; 
$ workbook = $ reader-> load(document.xlsx);
$ workbook-> -getActiveSheet() - > getSecurity() - > setWorkbookPassword(你的密码);


Can i create save password protected Excel file with php? I find the a lot of class and method and did't found thank you

解决方案

You can use (the excellent) PHPExcel for this. To lock a whole workbook:

$reader = new PHPExcel_Reader_Excel2007;
$workbook =  $reader->load("document.xlsx");
$workbook->getSecurity()->setWorkbookPassword("your password");

Or to lock a sheet:

$reader = new PHPExcel_Reader_Excel2007;
$workbook =  $reader->load("document.xlsx");
$workbook->-getActiveSheet()->getSecurity()->setWorkbookPassword("your password");

这篇关于我可以创建具有密码保护的Excel文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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