简体   繁体   English

有没有办法将私人谷歌电子表格中的数据显示为网站上的图表?

[英]Is there a way to display data from a private google spreadsheet as a chart on a website?

I am doing a project for my school. 我正在为我的学校做一个项目。 I have logged in the number of visitors who come to the school using a car, a bike, a bicycle or some other form of transport on a google spreadsheet. 我已经在Google电子表格中使用汽车,自行车,自行车或其他形式的交通工具登录了访问学校的访客人数。 I want to be able to display all the data in the form of charts on my school website in order to keep track of the CO2 emissions caused by people to come to school daily. 我希望能够在学校网站上以图表的形式显示所有数据,以便跟踪人们每天上学所造成的二氧化碳排放量。 I read about the google spreadsheet api but can't understand how to get data from the spreadsheet without making it public. 我读到了谷歌电子表格API,但无法理解如何从电子表格中获取数据而不公开。 Any help would be greatly appreciated. 任何帮助将不胜感激。 Thanks. 谢谢。

Yes definitely, write code in Google app script to get required data from spreadsheet, deploy your script ( anyone even anonymous option), change version of script each time when you are changing code and deploy again. 是的,在Google应用脚本中编写代码以从电子表格中获取所需数据, 部署脚本( 任何人甚至是匿名选项),每次更改代码并再次部署时都会更改脚本版本。

Get URL of deployed app script, do ajax call to that url from your javascript code (in your web application) and get required data and use it to show chart using any chart plugin from jquery. 获取部署的应用程序脚本的URL,从您的javascript代码(在您的Web应用程序中)对该URL进行ajax调用并获取所需数据并使用它来使用jquery中的任何图表插件显示图表。

no need to code this in apps script. 无需在应用脚本中对此进行编码。 Google sheets natively supports publishing charts. Google表格本身支持发布图表。

https://support.google.com/docs/answer/78052 https://support.google.com/docs/answer/78052

Depending on how you published the chart, its a different process to update the chart as the data changes. 根据您发布图表的方式,在数据更改时更新图表的过程也不同。 If you used "publish to the web", simply republish, or modify the URL to remove the range (with some caveats, see this help topic on ways to do it. Its an old post and the new sheets publish url may be different or allow open ranges (like A1:C). https://productforums.google.com/forum/?hl=en#!category-topic/docs/how-do-i/ZRpghByKHNM 如果您使用“发布到网络”,只需重新发布,或修改网址以删除范围(有一些警告,请参阅此帮助主题,了解如何执行此操作。它的旧帖子和新工作表发布网址可能不同或允许开放范围(如A1:C) .https//productforums.google.com/forum/?hl = en#category_topic / docs /how-do-i / ZRpghByKHNM

If you publish the chart inside a doc or presentation, see http://googleappsupdates.blogspot.pe/2016/05/embed-charts-from-google-sheets-in.html which is a more streamlined way to update the chart, but requires an intermediate doc/slide. 如果您在文档或演示文稿中发布图表,请参阅http://googleappsupdates.blogspot.pe/2016/05/embed-charts-from-google-sheets-in.html ,这是更简化的更新图表的方式,但需要一个中级文档/幻灯片。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM