views:

309

answers:

2

We receive Excel workbook files every day which are password protected with the same password. We know this password. Is there a utility or method to remove password protection on these workbook files without invoking Excel.exe or the Excel object. Our goal is to take Excel out of the process and utilize SpreadsheetGear in VB.net. However, SpreadsheetGear can only unprotect worksheets not workbooks.

Thanks

+2  A: 

You just need to set the Password property of the workbook to an empty string. In Python:

from win32com.client import DispatchEx
xlApp = DispatchEx("Excel.Application")
xlApp.Workbooks.Open (mySpreadsheet, Password=myPassword, WriteResPassword=myPassword)
xlWB = xlApp.Workbooks[0]
xlWB.Password = ""
xlWB.Save()
xlWB.Close(False)
xlApp.Quit()
Greg
Greg, Thanks for the response. Unfortunately this misses the mark since it will still launch Excel.exe. I need some way to work with the file that doesn't involve the Excel object or exe.
cookes
Um, if you don't want to run Excel on a server, you may still want to reconsider. The Excel API has a few options for instantiation. One is to always use a new instance; this keeps multiple processes from stepping on each others' toes. Memory usage is maybe 20MB each - for the whole 1 second that it will be running.
Greg
I agree, but we're already running Excel on the server and my boss would like to get it out of the process.
cookes
Waitaminnit here... you receive encrypted Excel spreadsheets and yet youur goal is to process something other than Excel... Dude, your solution is to tell your client to send you something other than Excel! Really, Excel is a great solution for some problems, but it sounds like you should be demanding something else like CSV...
Greg
A: 

Are they XLS or XLSX files?

for XLSX apparently you can use the RMS SDK to work with encrypted XLSX storage format. http://msdn.microsoft.com/en-us/library/aa767782(VS.85).aspx

Looking at it though its just a spec with almost no code samples so best of luck with that. once you have access to the underlying xml you can use standard xml namespace from .net or java to work with the file.

2003 (XLS) format, unless you use a propietrary 3rd party vendor solution that supports programmatic access (not aware of any specific products) you are out of luck.

Anonymous Type