You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Nilesh Naik <ni...@gmail.com> on 2011/02/15 08:45:13 UTC

Adding password protection to excel files

Hi All,

We have a requirement wherein we need to add password protection to already
generated excel files (through some ruby code). Please let know if this is
possible via POI.

Regards,
Nilesh

Re: Adding password protection to excel files

Posted by Nilesh Naik <ni...@gmail.com>.
The requirement is to open a existing workbook & apply password.
We are using the below  URL for reference>> *
http://www.salesclic.com/le_coin_du_geek/using-apache-poi-with-ruby-to-generate-excel-spreadsheets/
*

and here is the code we have written
   apache_poi_path = 'C:\Users\ABC\Desktop\poi-3.7\poi-3.7-20101029.jar'
Rjb::load("#{apache_poi_path}", ['-Xms256M', '-Xmx512M'])
file_class = Rjb::import('java.io.FileOutputStream')
workbook_class = Rjb::import('jxl.Workbook')
workbook_class = Rjb::import('org.apache.poi.hssf.usermodel.HSSFWorkbook')

book = workbook_class.new

sheet = book.createSheet('Password')

sheet.protectSheet("ruby")

out = file_class.new('C:\Users\..........\nilesh.xls')
book.write(out)
out.close

On Tue, Feb 15, 2011 at 1:41 PM, Mark Beardsley <ma...@tiscali.co.uk>wrote:

>
> It might be. Which file version are you targetting - binary or XML - and
> what
> exactly do you mean by password protection? HSSF can, for example write
> protect the workbook whilst XSSF defines methods that allow you to exercise
> much more granular control over the protection applied to the workbook.
>
> Yours
>
> Mark B
> --
> View this message in context:
> http://apache-poi.1045710.n5.nabble.com/Adding-password-protection-to-excel-files-tp3385589p3385617.html
> Sent from the POI - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>
>

Re: Adding password protection to excel files

Posted by Mark Beardsley <ma...@tiscali.co.uk>.
It might be. Which file version are you targetting - binary or XML - and what
exactly do you mean by password protection? HSSF can, for example write
protect the workbook whilst XSSF defines methods that allow you to exercise
much more granular control over the protection applied to the workbook.

Yours

Mark B
-- 
View this message in context: http://apache-poi.1045710.n5.nabble.com/Adding-password-protection-to-excel-files-tp3385589p3385617.html
Sent from the POI - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org