Secure your data exports - encrypt and password protect sensitive CSV and XLSX files
npm install secure-spreadsheet:fire: Secure your data exports - encrypt and password protect sensitive CSV and XLSX files
The Office Open XML format provides a standard for encryption and password protection
Works with Excel, Numbers, and LibreOffice Calc

Install the CLI
``sh`
npm install -g secure-spreadsheet
Convert a CSV into password-protected, AES-256 encrypted XLSX
`sh`
secure-spreadsheet --password secret < input.csv > output.xlsx
Protect an existing XLSX
`sh`
secure-spreadsheet --password secret --input-format xlsx < input.xlsx > output.xlsx
You can use the CLI to create encrypted spreadsheets in other languages.
Pull requests are welcome for more languages.
` $csv_str = "awesome,csv"; $descriptorspec = array( $process = proc_open(["secure-spreadsheet", "--password", "secret"], $descriptorspec, $pipes); if (!is_resource($process)) { fwrite($pipes[0], $csv_str); $result = stream_get_contents($pipes[1]); if (proc_close($process) != 0) { file_put_contents("output.xlsx", $result);php`
0 => array("pipe", "r"),
1 => array("pipe", "w")
);
die("Command failed");
}
fclose($pipes[0]);
fclose($pipes[1]);
die("Command failed");
}
`python
import subprocess
csv_str = b'awesome,csv'
result = subprocess.check_output(['secure-spreadsheet', '--password', 'secret'], input=csv_str)
with open('output.xlsx', 'wb') as f:
f.write(result)
`
`ruby
require "open3"
csv_str = "awesome,csv"
result, status = Open3.capture2("secure-spreadsheet", "--password", "secret", stdin_data: csv_str)
raise "Command failed" unless status.success?
File.write("output.xlsx", result)
`
An alternative approach to secure your data is to create a password-protected ZIP archive. However, this leaves the data exposed after it’s unzipped.
The content type for XLSX is application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.
Thanks to xlsx-populate for providing the encryption and password protection.
View the changelog
Everyone is encouraged to help improve this project. Here are a few ways you can help:
- Report bugs
- Fix bugs and submit pull requests
- Write, clarify, or fix documentation
- Suggest or add new features
To get started with development:
`sh``
git clone https://github.com/ankane/secure-spreadsheet.git
cd secure-spreadsheet
npm install