Pushing data to Google spreadsheet through JavaScript running in browser

前端 未结 2 883
暖寄归人
暖寄归人 2020-11-30 21:08

I am working on an web application where I would like to allow the user to push data to her own Google spreadsheet.

Firstly I tried to use Google APIs Client Library

2条回答
  •  萌比男神i
    2020-11-30 21:22

    I was looking into this too about 8 months. I stumbled across a blog post written by Martin Hawskey. I followed the guide here and I was able to set up a HTML form posting to a spreadsheet.

    Effectively you set up a published web app inside the spreadsheet that can receive the data. To get around the CORS issues you target a hidden iframe on the page. I would replicate the code in this post but there is a fair bit of it.

    DEMO

    • Here is the HTML form.
    • Here is the spreadsheet receiving the data.

    I'll provide some advice that I wish I was given when I started looking at this. If you can... try and set up a PHP server you can use. Posting the data is a lot easier and flexible. I now use Zend GData religiously at work and wish I had found it sooner :)

    EDIT

    Marting Hawskey has updated this to support a AJAX submission without the use of a hidden iframe. See here.

提交回复
热议问题