How to embed Google docs collection in iframe?

I have a collection of Google Docs that I would like to insert in an iframe:

https://docs.google.com/open?id=0B6yYgWS-CUJ2ZTUxZGI4MGUtMWM0Yy00YzY0LWIxOTMtMDFlN2RjNDAxNGM2

The problem is that Google set the X-Frame-Options header, and therefore it seems that they only allow you to embed this collection in the Google site:

 X-Frame-Options: SAMEORIGIN 

screenshot-with-shadow.png

Now I am aware of the reasons why Google sometimes does not allow their content in frames, but this is one of the cases when it seems to me that it would be nice to be able to do this.

With documents, Google also allows two methods of "sharing"

  1. You can click on the "Share" button and set the visibility, which will give you a link to the document
  2. Or you can click "Publish on the Internet" and it will give you a link or iframe option.

The iframe URL is similar to the URL of the link, except at the end it contains the request variable " &embedded=true ". The same applies to Google Maps, except for the parameter " &output=embed "

Although someone believes that I can’t do anything with the headers or Javascript on my site to allow the loading of iframe content for the Google Docs collection, I was hoping someone could know how to create embed code for the Google Docs collection. which would allow it to be loaded into an iFrame.

+6
source share
2 answers

Update. It looks like Google has allowed embed elements of Google Docs / Drive through iFrame. Here are the current headers for this page (note that this URL is after the redirect):

enter image description here

+2
source

Try the following: -

single - setting to true displays only one sheet in the spreadsheet. The default sheet that it displays is the first one created in the spreadsheet. This can be changed using the "gid below".

gid - this should be the numeric identifier of the sheet you want to display. The first sheet created is 0, but others will have longer identifiers. To find the "gid for the sheet you want to display, go to the spreadsheet in Google Apps itself and click on the sheet you need. The URL of your browser should change to something like this: https://docs.google.com/a/mycompany .com / spreadsheets / d / 15B ___ SOYjsRmU9tiwZly318HZnFHOHeayS6U thanks7Pu2I / edit # gid = 419657423

The bit at the end of the URL shows you the "gid for the worksheet" and this is the number you need to enter in the short code on your website.

Range

- set this to the range of cells that you want to display on the sheet (or leave it to display the entire sheet). In our example, we set this to f2: g6. Note that if you'rere pedantic, you should really change the ": to"% 3A, since the colons should be encoded in the urls, but most browsers should understand the colon, so don't worry. If you like to be true, you use the range = f2% 3Ag6 instead.

headers = false - Row and column numbers are not displayed.

widget - setting this value to false removes the sheet selection panel when it is inserted.

chrome - setting this value to false removes the title bar that displays the table name above the sheet.

So, all together: -

 <iframe> src="https://docs.google.com/spreadsheets/d/[Googlekey]/pubhtml?gid=28&range=a1:s45&single=true&widget=true&headers=false" </iframe> 

Allan

0
source

Source: https://habr.com/ru/post/907436/


All Articles