3

I've been researching javascript, jquery, xml, google scripts, and the google spreadsheet api, with little luck. I'm trying to create a website that uses a google spreadsheet as a database. It needs to run on a chrome book.

Hosting sites on google drive doesn't seem to allow jquery. So I can only use html, css, and javascript, that I know of. I usually create asp.net sites with a C# backend, but I can't seem to figure out how to even get data from a published google spreadsheet to display on a google drive hosted website.

Do any of you have a path that you would suggest? I'm all for researching myself but I need a good starting point which I have yet to find. Thanks

Luk6e
  • 170
  • 2
  • 12

1 Answers1

1

There is a GitHub library for PHP, if your site happens to use PHP

github.com php-google-spreadsheet-client

There are a few options:

  • Google Sites - With a Google Stand Alone HTML Apps Script in a Apps Script Gadget
  • Google Stand Alone HTML Apps Script
  • Website that Uses the Sheets API

If you try to access a Google sheet from a website with a different domain name, you will get a CORS error. CORS is a Cross Origin Resource Sharing. Each option for connecting to a spreadsheet has it's own issues. If you use a Stand Alone HTML App with Apps Script, you can't have a domain name. A free Google Site, doesn't have a domain name, but it's a nicer URL, and a Google Site can be mapped to a domain name. A website with a regular domain name, will require an API to do something with Sheets. The documentation for the Sheets API show examples written in Protocol, Java, and .Net. But, the documentation states:

A number of client libraries are provided in various languages. These client libraries make it easier to interact with the Sheets API.

But I don't see any reference to where all these various languages are.

I don't know of any easy to understand documentation for using a Google spreadsheet as a data source from a website. So, unfortunately, I don't know of an easy answer. The answer depends on what you want/need, and how much time and skill you have to set it up.

So, do you need a domain name or not? You can map a Google Site to a domain name:

https://support.google.com/sites/answer/99448?hl=en

But the documentation also states:

You can't map your domain to what is known as a naked domain, such as http://example.com

If you need to use a website and connect to the Google spreadsheet with an API, you'll need to run an authorization. Otherwise, any website could read/write to your spreadsheet.

Obviously there are websites that write data to Google spreadsheets, so it's possible.

You can also look at posts like this:

google-spreadsheet-api-with-php

how-do-i-access-the-google-spreadsheets-api-in-php

Alan Wells
  • 30,746
  • 15
  • 104
  • 152
  • Thanks for the detailed response, I don't need a domain name and there are a few ideas here I have yet to come across. I will explore them and post back. Thank you – Luk6e Apr 02 '15 at 17:35
  • In your case, you could use a Google Site, with an Apps Script embedded in the site. Apps Script HTML Service can do almost anything. I would just design all the HTML in Apps Script, and not try to do much with the Google Site, except for embed the Apps Script in an Apps Script Gadget. – Alan Wells Apr 02 '15 at 21:29
  • I was down that road before you commented back. It seems to be working, App Script is in java so development is slow, but the question was a place to start and you have given a working one. Thank you. – Luk6e Apr 02 '15 at 23:24
  • You can use jquery in Apps Script. [Google Documentation](https://developers.google.com/apps-script/guides/html/restrictions#javascript) Might need to use an older version. – Alan Wells Apr 03 '15 at 00:21
  • Im not sure the php info is relevant. The rest is good. Seems asker wants somerhing that is pure frontend or doesnt require a backend to maintain. So apps script is ideal. You can use the sheets api from frontend but in your case it would only make sense to read and never write to it otherwise you will have security issues. – Zig Mandel Apr 05 '15 at 01:32