I have a spreadsheet loaded in an iFrame. Outside the iFrame I have a button. When the user clicks the button. I need to retrieve the data in the current row. Any suggestions on how to do that?
Yes, you can write a script and publish it as a web app that acts as an API. You could use this to query the spreadsheet in the context of an authorized user (Google account) and get the data. The script would use the ContentService and give you back TextOutput of mimeType JSON (or Atom, RSS, XML or text). This is just new functionality but the doc is in place. See https://developers.google.com/apps-script/service_content
Related
Using API to get access_token and now I need to open Google Sheet.
Step 1.
Authorization: Bearer ya29.a0AV...." together with link: "https://docs.google.com/spreadsheets/u/0/d/[DocumentFileID]/edit"
Step 2.
Now HTML document back (~200kb). I'm using libcurl for that.
The problem is - missing are some css and js files and I see document just partially. Is there any way to open/edit Google Sheet using API?
I know for the option to just open https://docs.google.com/spreadsheets/u/0/d/[DocumentFileID]/edit in the new browser tab, but in that case I need to manually login to Google and that's what I try to avoid, because I want to use API to login and to open/edit a Sheet.
I also know for the option to share a document but I also try to avoid that. I'm writing application to customers who can access they own documents once they confirmed API usage.
I think you may have misunderstood what the google sheets api can do
The Google Sheets API is a RESTful interface that lets you read and modify a spreadsheet's data.
It gives you access to the data, it does not allow you to open the google sheets web application. Your going to have to code your own google sheets type app if you want users to open sheets directly.
I've created a small electron app that shows data from a google sheet via sheetrock.js to display table data. I've added a form that submits data to the google sheet with the help of triblondon's git
Now I'm trying to Implement a simple button on the electron app that will move populated rows from one sheet to another, creating a history. But for the life of me, I can't find a method of doing so that doesn't involve sending json data like the method above, writing to a cell and just doing formulas from there.
I'm just looking for a simpler, more direct approach by just invoking a function on the google script side (button + javascript probably).
Thanks for any help you can provide.
You can deploy your script as apps script. You will have use the public URL to be triggered by your button.
You can check everything about it on the Web Apps documentation.
I would like to open a Google Spreadsheet with a few parameters.
Can I add these few parameters in the URL to open the spreadsheet, and then in the spreadsheet load these into some cells?
The spreadsheets in question are privately shared, and the users using the URLs is granted permission to edit.
Sandy Good provided an interesting answer and that workflow is indeed the only possible one but there is a major issue in that a webapp deployed this way won't be able to "open" your spreadsheet in the common sense of "open", ie open in a browser window to work on it normally.
At least not without a user action like a click on a link that would open the sheet in a new tab. Finally you would have a 2 steps process:
Launch the webapp via an URL with parameters that would write some values in the spreadsheet without seeing it and
Open the spreadsheet using a link shown in step 1... retrieving the values that step 1 wrote in some cell
Very cumbersome and nothing would prevent users to go directly to the spreadsheet without using your special URL...
All in all , it would be useless.
So I'm afraid the real answer it simply "no, not possible"
Here is a table of triggers that are available to the different Google Products:
Available Types of Triggers
In a Stand Alone app, you can run a doGet() function. The doGet() function runs automatically. There is an e.parameter option available to doGet(e) that will parse URL search string settings. But a doGet() function can't be added to a Sheet.
The URL parameters that are available are listed in this documentation:
URL Parameters
But, those URL Parameters are for Web Apps and Google Sites Gadgets, not for a Google Sheet.
You could have an intermediary Google Apps Script that you send the URL Request to, and then the Apps Script processes the URL Search String parameters, and then opens up the spreadsheet.
So, instead of using the Google Sheet URL to open the spreadsheet, you'd be using a URL of the deployed web app. Then the user would need to click a link to open the spreadsheet.
Once the web app parsed the URL Search string values, you would need to write some kind of script that did something like write those values into your spreadsheet using the Spreadsheet Service
I want to styling embedded Google Drive form. So I create form at Google Drive, run it and copy source code from <form> to </form>. All looks good but when I select form values and click on submit button data sended to Google Drive spreadsheet are blank. If I use iframe that Google recommend all sended data is not blank. What I do wrong?
It sounds like you're viewing the source code from google drive, and copying that into an I-Frame on your own webpage. This won't work since that source code is offline, reserved for sending and receiving data from google only.
I recommend creating your own excel-like spreadsheet in your I-Frame. You may be able to use the same submit button if you configure it to send to your server.
I want to automate the process of transferring data that a form user submits (on a Google Doc Form), to a separate document (a Google Doc Document) that has empty fields for this data.
For example the person's name or DOB entered on the form would automatically get transferred to an area of the document where I would like it to appear, amongst other pre-existing information in the Document.
There is an option to link the form to a spreadsheet on Google Forms. Just click "Choose response destination" to set it.
With the introduction of the Forms Service in May 2013, you have a couple of options to accomplish this.
A script bound to your Form can modify a Document. A form-bound script will receive a Form Submit Event with a FormResponse object. Your script would use Document Services to open and modify a document with content of the FormResponse.
A script bound to a spreadsheet that is receiving Form input can modify a Document. A spreadsheet-bound script will receive a Spreadsheet Form Submit Event. Again, use Document Services to update your document.
References:
Understanding Events
Extending Google Docs / Replacing Text shows how to replace placeholders in a target document.