1. Publish a sheet to the web by going to File – Publish to the web. Click on Embed and grab the iframe embed HTML code. I publish the “Entire Document,” but you can be more specific by clicking on the down arrow next to “Entire Document.” I also let it update automatically. Here’s what it looks like in Google Sheets:
2. Below is what my iframe code looks like after I add and modify the parameters, which are everything that comes after the “pubhtml?” part of the “src” URL. I’m talking about “gid” and “widget” and “headers” and “chrome” and “range.”
If a parameter can be turned “on,” set it as “=true” to do so. For off, set to “=false.” The “gid” and “range” parameters take other values, which you can see in the embed code examples.
If you are wondering, that
"&" is the HTML entity for an ampersand (&). It connects the different parameters into the single URL.
Note that you will need to change the iframe URL and the parameters in the embed code to match your own spreadsheet’s details and preferences. Below you can see an example:
Another note about the “gid” parameter: You see that “gid=0”? You get that from the URL of the spreadsheet tab you are actively looking at. Here are two images of the URL of my sheet with the “gid” part highlighted:
Another note about the “range” parameter: You manually specify the range in the “range=” part of the URL. This is the “&range=A1:C26” that you see in the URL of the embed code.
Here’s a live example of the working embed code. I include the embed code inside a cell for reference:
Below is an embed of the second sheet within the same test project. To embed this specific sheet, I had to click on its tab within the project to make it active, then inspect the URL that gets loaded. That URL contains the gid number. It’s not something simple or logical like “2” or “1.” In my case, it was 2106886376, as the image above shows. So all you do is change the functioning embed code to reflect that.
So here’s what the embed code for the 2nd sheet in my project looks like. Notice how the “gid” part of the URL has changed. I also adjusted the width and height of the embed, just to show you what those configurations are doing:
And below is the result:
That’s it! Add your questions in the comments or email them to me at firstname.lastname@example.org. Good luck!
If you found this helpful, consider donating through PayPal:
Update Sept. 5, 2021: It seems Google has updated their embedding capabilities, making it easier to some degree. This support page lists some useful parameters to toggle using “true” and “false” in the URL of the embed code. The “chrome” toggle is likely very useful to most people. I’ve updated my guide below to reflect those changes.
Update March 30, 2020: The coronavirus disease 2019 (Covid-19) I suspect has greatly increased interest in using remote collaborative tools such as Google Sheets, Docs, and other Suite tools offered by the company (not to mention Slack, Zenkit, FaceTime, and on and on). Given that, I have tried to increase the visibility of this post. Thank you and best of luck making it through this global crisis.
Update April 14, 2014: With the help of a Good Samaritan reaching out to me via email, a solution has been found for embedding specific ranges of the new Google Spreadsheets (they were updated in early 2014) onto your site.