I would like to know is there any way, screenshot could be taken in Google Sheets using Google Apps Script. I browsed I couldn't see this question or answer anywhere.
Or can it be done in any other way if not using Google Apps Script.
You will not be able to take a screenshot with apps script. It's not possible to use the HTML features others mention because of security restrictions, either your script interface runs with iframe mode, or using caja, either way you can't access the parent window and caja will block those html5 methods.
Your best option is to use Google Apps Script to convert the sheet into PDF.
If you have trouble converting to PDF, see this other answer: Google Apps Script - Create PDf from Spreadsheet produces pdf of Google sign in page.
Use a javascript library such as this:
http://www.jquerybyexample.net/2013/08/take-webpage-screenshot-html5-jquery-javascript.html
It may be in violation of Google policies though, as it is blocked by them:
Here is a tutorial that explains how can you achieve this: https://blog.rasterwise.com/how-to-take-a-screenshot-on-google-sheets/
Essentially you can use a cloud screenshot API and instrument Google App Script to invoke the API as a function in Google Sheets.
This basically allows you to have a list of URLs that you can pass as parameters of the custom function as shown in the screenshot below:
Related
I'm working on an html file in a google apps script project right now and I want it to be able to retrieve the html content of a web page, extract a snippet, and paste the snippet to the page. I've tried using fetch() and a couple of its options (mostly CORS), but I either get nothing back or an error that says "No 'Access-Control-Allow-Origin' header is present on the requested resource." A workaround I found was using google.script.run.withSuccessHandler() to return the html content via UrlFetchApp.fetch(url).getContentText(). The problem with this is that it is time consuming and I want to try and optimize it as much as possible. Does anyone have any suggestions on how to make this work or will I be forced to stick with my workaround?
Using "Vanilla JavaScript" in a Google Apps Script web application might not work to
retrieve the html content of a web page, extract a snippet, and paste the snippet to the page.
The above because the client-side code of Google Apps Script web applications is embedded in an iframe tag that can't be modified from server-side code. In other words, Google Apps Script is not universally suitable web development platform. One alternative is to use another platform to create your web application, i.e. GitHub Pages, Firebase, etc.
Related
Where is my iframe in the published web application/sidebar?
I want to get started with the Google Calendar API and my idea was to just setup a simple HTML site I can directly open in the browser.
From this site I want to for example create an event in Google Calendar.
Is this possible (and how), or can I only access the Google Calendar API from a server?
Thanks in advance!
It's possible, but not so well supported by google. If you have a quick look at google developers, you'll find what you need. Including a quickstart and how to insert an event.
Also mind the authorizations you'll need calendar instead of calendar.readonly
I would like to have a Chrome Extension interact with the contents of a Google Doc - specifically to add text and ideally html to a document with the click of a button in the Extension popup.
I've read that a Google Extension can 'talk' to a Google Docs Script - to gain access to the script model and its commands.
Can you hand off a string from a Chrome Extension and have a Google Docs Script take that string and then insert it into the document (at the cursor location, for instance)?
Would the user have to manually approve the script each time it was called? Or just installed once and then the process runs in the background?
A commenter gave a very helpful link to a similar need and solution for Google Sheets. But that solution (see comments below) depends on Google Sheets APis and there does not seem to be an equivalent Google Docs API.
I've been researching javascript, jquery, xml, google scripts, and the google spreadsheet api, with little luck. I'm trying to create a website that uses a google spreadsheet as a database. It needs to run on a chrome book.
Hosting sites on google drive doesn't seem to allow jquery. So I can only use html, css, and javascript, that I know of. I usually create asp.net sites with a C# backend, but I can't seem to figure out how to even get data from a published google spreadsheet to display on a google drive hosted website.
Do any of you have a path that you would suggest? I'm all for researching myself but I need a good starting point which I have yet to find.
Thanks
There is a GitHub library for PHP, if your site happens to use PHP
github.com php-google-spreadsheet-client
There are a few options:
Google Sites - With a Google Stand Alone HTML Apps Script in a Apps Script Gadget
Google Stand Alone HTML Apps Script
Website that Uses the Sheets API
If you try to access a Google sheet from a website with a different domain name, you will get a CORS error. CORS is a Cross Origin Resource Sharing. Each option for connecting to a spreadsheet has it's own issues. If you use a Stand Alone HTML App with Apps Script, you can't have a domain name. A free Google Site, doesn't have a domain name, but it's a nicer URL, and a Google Site can be mapped to a domain name. A website with a regular domain name, will require an API to do something with Sheets. The documentation for the Sheets API show examples written in Protocol, Java, and .Net. But, the documentation states:
A number of client libraries are provided in various languages. These client libraries make it easier to interact with the Sheets API.
But I don't see any reference to where all these various languages are.
I don't know of any easy to understand documentation for using a Google spreadsheet as a data source from a website. So, unfortunately, I don't know of an easy answer. The answer depends on what you want/need, and how much time and skill you have to set it up.
So, do you need a domain name or not? You can map a Google Site to a domain name:
https://support.google.com/sites/answer/99448?hl=en
But the documentation also states:
You can't map your domain to what is known as a naked domain, such as http://example.com
If you need to use a website and connect to the Google spreadsheet with an API, you'll need to run an authorization. Otherwise, any website could read/write to your spreadsheet.
Obviously there are websites that write data to Google spreadsheets, so it's possible.
You can also look at posts like this:
google-spreadsheet-api-with-php
how-do-i-access-the-google-spreadsheets-api-in-php
While looking to process a few variables from a form, and send that data to a Google Drive Spreadsheet, I found that Google Apps Script, fits better for my purpose, it just catchs all the data in a regular html form, and sends that data to my Google Drive Spreadsheet, without depending on a special type of google form, and without matching var names, vith values.
Am I missing something?
Regards!
Google Tag Manager gives you the power to create and update tags for your website and mobile apps, any time you want, at the speed of your business. You can go through the documentation here.
You can also refer to this page for more idea on what Tag manager is.
For your requirement of getting the data from a form to a Google Spreadsheet, Google Apps Script fits better.
You can refer to these links for more information of Appscript:
https://developers.google.com/apps-script/guides/sheets#connecting_to_google_forms
https://developers.google.com/apps-script/guides/html/
Hope that helps!