encrypt
encrypt
PREMIUM
BASIC / ADVANCED
Encrypts an Excel spreadsheet.
Description
public encrypt($source, $target, $options)
This method allows to encrypt an Excel spreadsheet. The final user needs to insert the password included in the options array to access the content of the resulting file.
The encrypted file is a Microsoft Binary Compound File that is directly recognized as an encrypted Excel spreadsheet by the standard Excel interface.
Parameters
source
Path to the Excel spreadsheet that you want to encrypt.
target
Path to the resulting encrypted file.
options
The possible keys and values are:
Key | Type | Description |
---|---|---|
password | string | The password should be a string of 15 or less characters. If you introduce a password with more than 15 characters it will be automatically truncated. |
Exceptions
The source file doesn't exist.
A password is not set.
Code samples
Example #1
Release notes
- phpxlsx 4.0:
- supported files bigger than 6.5MB.
- phpxlsx 1.0:
- new method.