问题
Is there a way for Google Apps Script to open a password-protected Excel file if the password is supplied when getting the file? I don't see any DriveApp method that accepts a "password" parameter.
If not, then can this be implemented using the Google Drive API? Is there a "password" key I can use in an "options" object of a gapi.client.drive.files.get() or a similar method?
回答1:
No, that is not possible with Apps Script or Google APIs at this time.
You can always file a feature request in Google's Issue Tracker with something along the lines of "Support Excel Password functionality in Drive / Sheets API". From what I could see, there are no existing feature requests for this isssue.
The latest news that I could find, that Google have published about password protected files is this blog post, which mentions that now you can preview password protected items in Drive.
The guides Google provide here and here regarding Microsoft Office files detail the functionality that is available. Yet none of it refers to Apps Script, APIs or passwords.
The only possible workaround I can think of is to un-protect them with VBA or other language before they are uploaded to Drive, or send them to an app that can deal with them and send them back (I know, that may be painful).
来源:https://stackoverflow.com/questions/64377823/google-apps-script-to-open-password-protected-excel