javascript - extracting data from google spreadsheet into a html table - Stack Overflow

I have a google spreadsheet that stores data at my work and is constantly being updated via google driv

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.

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.

Share Improve this question edited Jan 9, 2015 at 17:46 Dan McGrath 42.1k11 gold badges103 silver badges130 bronze badges asked Jan 4, 2015 at 9:52 thechrishaddadthechrishaddad 6,7458 gold badges29 silver badges34 bronze badges 1
  • 1 You can try and fetch the info from the sheet as json: developers.google./gdata/samples/spreadsheet_sample once you get it - it will be easy to embed it in your website. – Ido Green Commented Jan 6, 2015 at 10:12
Add a ment  | 

1 Answer 1

Reset to default 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./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./spreadsheets/d/1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms/gviz/tq?tqx=out:html&tq&gid=0


Hope that helps.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745112618a4611935.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信