Google Apps Script to open password-protected Excel? - excel

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?

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).

Related

Prevent Google Drive to exclude cell protection parameters from Excel file

I'm having some trouble in keeping protected ranges from Excel files in Google Drive.
In this link there is an original Excel file with a protected cell in OneDrive and in this other link is this very same file but in Google Drive. You can see that when I put the files in Google Drive it just kills the original protection from Excel. Is there a way to prevent it?
I am afraid that both features are completely different and not compatible yet. Microsoft's cell protection feature works only when using Office. If you upload and open the document in Google Drive, Google does not have a way to read the protection included by Microsoft as Google implemented their own cell protection feature as well.
For example, Google's protection feature works similar to the sharing permissions, based in users and email addresses, while Microsoft's protection gets implemented within the document itself.
Google added a compatibility mode for office documents not long ago, so it may be possible that this is available in the future, however at the moment there is no way to merge both protection features.
References:
Work with Microsoft Office files
Edit Office files

Error Opening password protected excel file with google app script [duplicate]

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?
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).

SharePoint CSOM: Open .docx file in Word Online (Office 365)

I have written some code to connect to a SharePoint online server and get a list of *.docx (Microsoft Word) files from a folder on there.
I then display this list of files in a web page and each file is a tag, so that the user can click on it and "open" the file.
When the user clicks on the file, it prompts the user to Open/Save the file (the standard IE/Chrome file open/save dialog). Instead, I want the file to open up in Word Online (in the same/separate browser tab).
I tried searching for possible API support online, but can't seem to find any. SharePoint Online itself seems to be able to do this. If you click on a .docx (or any other Office file), it will open it in Office 365 (provided you have that provisioned).
Any help would be greatly appreciated.
You need to add the appropriate parameters to the link that the user clicks on.
Have a look at an existing document library and see the links that it creates:
https://mytenant.sharepoint.com/_layouts/15/WopiFrame.aspx?sourcedoc={1767368F-62FB-4C40-B3F2-C4EE44E88735}&file=My%20Document.doc&action=default
If the user is not licensed for Office 365, I think that they will still be offered a download. Not entirely sure though as we don't allow that on our tenancy. Certainly if they are only provisioned with SP Online and not the rest of O365, they can view the document online but cannot edit. Though recently we've seen people still able to edit - not yet sure if that is one of Microsoft's secret updates or a mistake by them.
RESPONSES TO COMMENTS:
When I say not provisioned in the rest of O365, I really meant that they were licensed for SharePoint but not anything else (a P2 license rather than an E3), that doesn't give rights to use the online (or iPad) editors. As far as I know, the only real way to test for that is to either try it or to use an Admin account to look at the license.
You cannot "pass credentials" to WOPI since credentials for Office 365 applications come from a separate system. You have to get credentials before you are allowed to access anything in Office 365. Basically Azure AD is the service & the login is done via login.microsoft.com, the login provides a token to your browser that is exchanged with the server on every request. To reuse an existing credential, you have to be using an application that "knows" you have already logged in. Typically, Microsoft use a helper application that picks up the login from IE if that's how you logged in and makes it available to other applications such as Office. If you are using Firefox to log in, IE & Office may not know that you have done so (though there is a plugin for FF that gets installed if you let it which does the same thing).
By the way, if you know how it REALLY works, please don't shoot me down for trying to simplify the process for others. :)

Using SAS to write to external Sharepoint library

I need a routine for loading files (.html) onto a sharepoint library using SAS. The site is outside the firewall (am unable to use the 'map network drive' method).
The sharepoint library is configured with 'No versioning' etc, and my username / password has administrator privileges..
I believe there are easier ways (tools) to do it than SAS, so I'd just let SAS call some other process - e.g. if your SAS is on Windows, it could call (even generate) a Powershell script.
This http://poshcode.org/2122 seems to be a way.
I've done something similar with SAS calling curl to upload files to SAS webDAV server.
If you'd like a pure SAS way - it should be doable using new PROC HTTP as a web service call.
Refer to
http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a003286672.htm for SAS side and probably this http://msdn.microsoft.com/en-us/library/ff798339.aspx
for Sharepoint side.
Anyway, PROC HTTP seems interesting for some easier things.
I don't think you can use plain old SAS to do this. If you have the SAS Enterprise BI Server product, there is a component called "SAS Web Parts for Microsoft SharePoint", but that is really an interface between Sharpoint and the BI server (so you can display dashboards or run stored processes).
The "easiest" thing to do is create your html files and then use FTP to copy then to the SharePoint server. Of course, this requires an FTP server on the other end and you would want to engage the help of the Sharepoint administrator. I've done something similar myself. I don't know SharePoint myself but there is a way to set it up so that all content that shows up in a directory is automatically recognised.
There may be other solutions and I'd love to see them as well.
Sharepoint has this wonderful web interface. Basically what you do is open your web browser, works best in IE8+ and navigate to your site URL and open your document library. If you select Items in the Ribbon you can upload a document using their interface. :)
SharePoint already exposes several options, using legacy web service and the new rest services.
http://msdn.microsoft.com/en-us/library/ff798339.aspx

Excel 2007 Pass-Through Windows Authentication

I've created a simple (asmx) web service which returns a DataSet.
I've added the webservice to my Excel 2007 workbook using the Data -> From Web button and I'm able to view / refresh the data.
The problem comes when I need to secure the web service: I've turned on Windows authentication for the web service and the request uses SSL.
Unfortunately, the user's logged on windows credentials aren't used by Excel when trying to refresh the data - the refresh fails.
If I click on Data -> Connections -> Properties -> Definition -> Edit Query, only then am I prompted for my windows credentials and does the refresh then succeed.... not a problem for me, but not something I want every user of this spreadsheet to have to do... any ideas how to make the prompt come up when the refresh is attempted instead of having it fail??
Thanks!!
Update Answers so far are to do with SharePoint and Excel Services (neither of which are any use to me)... and one link for which "The following procedure does not apply to data that is retrieved from a text file or a Web query"... I just want a person with a copy of excel on his desktop machine to be able to update from a password-protected web service... is that so hard Microsoft??
Another Update Still no answers accepted - because no answers so far have provided a working solution ( Nice googling though - thanks guys ;-) )
While I haven't got SSL I can attest that Excel normally shouldn't ask you for authentication when using pass through authentication.
My guess is that you will need to add the destination website (with the https) to your trusted zone in IE. The effect should be that when you go to the website you shouldn't be challenged for your password at all. IE will now pass through the authentication credentials because the destination is in the trusted zone.
Once this is fixed Excel should treat it like a normal website.
Here's a link which talks you through adding your site to the trusted zone: http://www.nateirwin.net/2007/01/19/enabling-ntlm-authentication-in-firefox-and-internet-explorer/
The last time I dealt with this issue was in 2004. If I remember correctly, this is a bug in the Web Query technology in how the query deals with the SSL certificate. This is Excel 97 technology; therefore, fairly basic implementation.
After much research and troubleshooting, the only way around this issue is to create user and password parameters and post the web query. Using POST will keep the user/password hidden from prying eyes.
Following is my note from 2004: There is a problem with https, application/vnd.ms-excel, Internet Query (iqy), and Excel 2000/2002.
Have you checked out this question: What do I need to do to make Excel access a Web Query via HTTPS?
Excel's Web Queries Enable You to Populate Worksheets from Web Sites at http://msdn.microsoft.com/en-us/library/aa155714(v=office.10).aspx.
Sites requiring authentication and passwords provide additional
challenges. They may require coded workarounds or may be unsolvable.
Error message when you use Web query to a secure Web page () in Excel: "Unable to open" at http://support.microsoft.com/kb/290347.
XL97: How to Create Web Query (.iqy) Files at http://support.microsoft.com/kb/157482 is an invaluable resource. (There was a Web Query SDK once that I cannot find, but this article is a good replacement.)
Different Ways of Using Web Queries in Microsoft Office Excel 2003 at .
I don't know if this will help, but I faced a similar situation while importing data from a remote SQL Server Database. What I did was create a role inside the database itself, and assign any users who needed access to that role.
The data is updated into the workbook when the file is loaded using Microsoft Query, so I don't know how that might differ from how you have done things.
The biggest issue with doing it this way was to open the properties for the query and check the "Use Trusted Connection" box. This worked without an issue for me. Again, this was from a remote server, not a secure website. Hope this helps.
i hope this will help you : Refresh connected imported data
We had a similar situation at work, however, we are using Office 2010. I'm not sure of the limitations of 2007. Check out these links. The last two are specifically for Excel 2007.
Link 1: Configure Secure Store Service for Excel Services
Link 2: Ten Tips for Using SharePoint Server 2007 with Excel Services
Link 3: Plan external data connections for Excel Services

Resources