183 responses to “Saving Form Data to Google Spreadsheets Using PHP and the Google Docs API”

  1. Jeff

    Awesome work! I found your helper class very useful.

    Is there a way for someone to write a query that contains a regular expression or has some sort of “partial match” operator. See the SQL query below:

    SELECT * FROM database WHERE name LIKE ‘%Doe%’

    $myQuery = ‘name = [RE:(*Doe*)]‘;

  2. A Reader

    Very very useful article. I’m gonna try this out! Thank you very much!

  3. Jeff

    Your class was so well written that it was little effort to extend it to perform a partial match search exploiting your class methods and a brute-force use of PHP stristr( ) function.

    Your point is well taken on complexity. I have been thinking about doing some EC2 cloud stuff, but using the Google spreadsheet is really refreshing and unexpected approach to databasing on small jobs.

    Thanks again for your article and code tips.

  4. dmon

    Very simple and easy to use. For a while I was having a hard time making it work. First I had to uncomment the openssl enable in php.ini. Then still didn't work when I realized that I had to provide the correct username, password and document title. Then it worked! Silly me.

    Anyways, your helper class was designed for PHP 5. Is it possible to convert it to PHP 4 so as to make it work in our server? thanks.

  5. dmon

    I have read the Zend framework document and it is specified there taht it requires PHP 5 to work.

    Yes, I've tried XML responses, if I just want to read them. But to add data or change something, I guess there's no other way through it.

    Well, the only thing to do is to either upgrade to PHP5 or use a 3rd party site.

    Thanks for your help, I really appreciate the simplicity in it.

  6. dmon

    I noticed that there was no delete function in the helper class you developed. I tried to edit your helper class and basing my code from your updaterow function, I created a deleteRow function. Just want to share to everyone :)

    add this function in the google spreadsheet helper class:

    function deleteRow($search)
    if ($this->client instanceof Zend_Gdata_Spreadsheets AND $search)
    $feed = $this->findRows($search);
    if ($feed->entries)
    foreach($feed->entries as $entry)
    if ($entry instanceof Zend_Gdata_Spreadsheets_ListEntry)
    if ( ! ($entry instanceof Zend_Gdata_Spreadsheets_ListEntry)) return FALSE;
    return TRUE;
    return FALSE;

  7. dmon

    hi, it's me again.
    Just want to ask if is it possible in your updateRow function to specify a certain row using multiple conditions? In your example you only used one condition which was the ID.
    thanks again.

  8. dmon

    Oh thanks. But I think I hadn't made my question clear.
    Let's say there are 3 John Doe's in your table and you just want to search for the one with an email of iam@johndoe.com

    Anyways, I have found the solution. You'll just have to use “AND” in your query.
    $rows = $ss->getRows('name=”John Doe” AND email=”iam@johndoe.com” ');

    Thanks again. Keep it up! ;-)

  9. nikita_m

    Thank you, very good tool.
    One strange thing:
    try to update row by new value:
    $row = array
    “name” => “=sum(F:F)”
    Open spreadsheet and see #NAME? and explanation – unknown range name F
    If I copypaste cell value to another cell, I get correct calculation.

    Kindly advise what could be.

  10. BillyTheCzech

    Hi i am trying to add row to spreadsheet,
    however it is not working, anytime i try to add row… occures error

    PHP DOMException: Namespace Error in
    /srv/www/htdocs/magento/lib/Zend/Gdata/App/Base.php on line 211

    i was tracking this and found this:

    DOMDocument->createElementNS('http://schemas....', 'gsx:0')

    can anybody help me?

  11. sam

    ok here it goes ive had problems from the start with this and it only worked ever so often here are the errors

    Warning: require_once(Zend/Loader.php) [function.require-once]: failed to open stream: No such file or directory in C:\wamp\www\test\Google_Spreadsheet.php on line 172

    Fatal error: require_once() [function.require]: Failed opening required ‘Zend/Loader.php’ (include_path=’.;C:\php5\pear;C:/wamp/www//ZendGdata-1.8.1/library’) in C:\wamp\www\test\Google_Spreadsheet.php on line 172

    mind u i just downloaded it straight from the site and everything
    please help………

  12. sam

    i am going to attempt reinstalling wamp or xamp maybe that will fix it

  13. Alex

    So, I installed the libraries, ran the first php example you put up, and I got this error message:
    Fatal error: Uncaught exception ‘Zend_Gdata_App_Exception’ with message ‘A spreadsheet key must be provided for worksheet document queries.’

    any idea what’s causing this? thanks!

  14. 4fthawaiian

    Totally lovin’ you dude. Great post. Exactly what I wanted.

  15. sam

    ok i found out why my problem it was my free host they blocked files bigger then 500 kb lol

    and another question i have multiple sites i need this script to input post data in the spread sheet and i need to know how to get a list of worksheets and if it doesn exist create one….

  16. sam

    im currently useing
    but that fails sometimes because of the worksheet not existing

  17. sam

    alright well how about getting data from a specific cell such as
    $cell = $ss->getCell(“B:5″)
    can it do that?

1 2 3 8