3

I have a google spreadsheet that stores data at my work and is constantly being updated via google drive so it is always online editing, what I want to do is to be able to extract the values in those cells and have them show up in a HTML5 table on my website, what would be the best solution for this?

I did try one way which was to just embed the spreadsheet in a iFrame and have that refresh every 5 minutes, but the refresh loading is too slow and it causes issues with trying to get the spreadsheet to fit perfectly in the iframe everytime I refresh. these websites will be on display on TV screens so I dont want to be adjusting them regularly, they will auto refresh and be idle.

1

1 Answer 1

3

Your Google Sheet's rows/columns can be exported as a pretty minimal HTML table. You can grab that HTML and manipulate it however you like. Here's how to get it:

  1. Open the Sheet and find your file_id in the URL, and the gid for the specific tab you wish to export (you may have several spreadsheets within a single Google Sheet).

  2. Use this URL string, replacing <FILE_ID> and <TAB_GID> with your own:

    • https://docs.google.com/spreadsheets/d/<FILE_ID>/gviz/tq?tqx=out:html&tq&gid=<TAB_GID>

You can set the refresh/recalculation rate under File > Spreadsheet settings to be every minute, if necessary.


Example:

Here is a Google Sheet with some data. To export this as an HTML table, we take:

  • the file_id: 1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms and
  • the tab_gid: 0

from the URL and substitute those into the URL string (above), yielding:

https://docs.google.com/spreadsheets/d/1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms/gviz/tq?tqx=out:html&tq&gid=0


Hope that helps. 🍻

2
  • Can you explain where you found the documentation for the URL you composed for simple HTML table export? Looks close to what I'm looking for, but I want to follow up with it. E.g. what does all that tq mean?
    – Kalin
    Nov 14, 2016 at 4:36
  • 1
    You save me a lot of time! Thank you :)
    – tzi
    Nov 15, 2020 at 9:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.