Password protected excel file without encryption or zipping

All,

I have requirement to send password protected excel file in an email from unix/linux box without zipping it. Any help would be appreciated.

Thanks..

You can protect an XLS spreadsheet using the Perl Excel::Writer::XLSX module, but you'll probably have to install it first.

1 Like

Can you provide some more details on how to do it.

I think, something like this, but I'm unable to test it:

#!/usr/bin/perl

use Excel::Writer::XLSX;

my $in=shift;
my $pass=shift;

my $workbook=Excel::Writer::XLSX->new( $in );
$workbook->protect($pass);
$workbook->close();

You put that in a file, set it executable, and run it like

./protect.pl filename.xls 'password'

I just checked this module is not installed on unix server, Is there any other way of doing it?

I don't know any others offhand and you're equally unlikely to have anything else. The feature you're asking for is third-party pretty much by definition.

I have got this module installed but still it is not making the file password protected..

Using below code:

#!/usr/bin/perl


use strict;
use warnings;
use Excel::Writer::XLSX;


my $workbook  = Excel::Writer::XLSX->new( "TEST.xlsx" );
my $worksheet = $workbook->add_worksheet('TEST_FILE');
$worksheet->protect( 'drowssap' );
$workbook->close();

Does it at least protect it from modification? You are limited by the features of the excel file here...

As modern xlsx files are actually zip files and zip files support passwords I've attempted putting a password on an xlsx file with zipcloak to see if Windows/Excel will support that. It doesn't. Sorry.

The one way Windows actually seems to support what you need is exactly what you were asked to not do - put the file inside a password-protected zip file.