Creating encrypted xlxs files?

105 views
Skip to first unread message

Jan Maurits Faber

unread,
Jan 16, 2013, 4:40:14 AM1/16/13
to ax...@googlegroups.com
Axlsx does a fine job of generating xlsx files but I need them to be encrypted.
The current way I do it is open each one in Excel and save it with a password which is painful. Does anybody now of a workaround to do this scripted?
There seem to be some traces in the code of a project to offer encryption in axlsx, is there any status on how far this is along?

Jan Maurits Faber

unread,
Jan 16, 2013, 9:28:25 AM1/16/13
to ax...@googlegroups.com
Replying to myself in case anyone else comes here looking for the same thing, it took quite some googling but there is an easy solution: I found it's actually trivial to do with the "rb-appscript" gem:

  require 'appscript'
  excel = Appscript.app("Microsoft Excel")
  excel.open("/Users/myself/unprotected.xlsx")
  excel.active_workbook.password.set "secret"
  excel.active_workbook.save_workbook_as(:filename => "protected.xlsx")
  excel.active_workbook.close

randym

unread,
Jan 16, 2013, 6:20:42 PM1/16/13
to ax...@googlegroups.com
Hi Jan, 

While I am glad to hear that you have found a local solution to encryption, I am sorry to say that it is not anywhere close to being available for axlsx.
I spent a couple of months wrapping my head around mscrypo and the compound binary file format but failed to get it working. 

You can see the efforts on the mscrypto branch on github.

The relevant files are:

cfb.rb
ms_off_crypto.rb
storate.rb

I've been hoping that someone in the community would be willing to take up the torch. It is a dark area that I am sadly just not smart enough to work out.

Jan Maurits Faber

unread,
Jan 17, 2013, 1:39:37 AM1/17/13
to ax...@googlegroups.com
Thanks for letting me know & for the excellent work on the gem so far. I noticed that Apple's Numbers can't open encrypted Excel files which leads me to believe that implementation would be far from trivial. Perhaps they employed a security through obscurity tactic because the encryption for older Excel versions was so easy to crack.
Message has been deleted

Gerome John Pangan

unread,
Oct 21, 2020, 11:45:23 PM10/21/20
to axlsx
any other implementation in the latest rails?
Reply all
Reply to author
Forward
0 new messages