Thursday 9 April 2020

Google Sheet API | Part 2 | Create New Sheet | Add & Update Cell Values


------------------------------------------------

Download VENDOR Folder (Only for PHP version 7.2+): https://unpossiblepog.com/research-and-development/php/Vendor-Folder-For-Google-Sheet-Drive-Calendar-With-PHP-Version-7.2-And-Onward

Hey guys, this is UNPOSSIBLE POG.
In previous part, we saw how to connect GOOGLE SHEET with PHP, and display data. If you haven’t watch that, then you can click on top corner or link is given in the description.
In this part, we shall learn how to create new spreadsheet and how to add & update data in it.
First of all, I shall get rid of those comments.
Then first we shall learn how to create new spreadsheet.
Go to the link that I provided in description, copy the code in PHP tab, comment previous display code, from below service variable up to bottom.
We shall paste it here.
Add any title you want.
And execute it.
It will respond with spreadsheet ID.
Lets go to google sheet’s home page, and you will find that spreadsheet.
Remember that newly created sheet always creates subsheet named “sheet1“ inside it by default.
I shall just delete it because I am not going to use it.
Next is to add & update data in out sheet.

We shall need spreadsheet ID and range.
Go to the description and click on "Add / Update spreadsheet values” link.
Skip that “Writing to single range”, because it is useless.

But before that, we shall append values, means add new rows in spreadsheet.
Copy the code, paste it after range.
Now I am going to add two new rows. So follow my format.
Notice that we are only adding 3 columns that is from A to C.
2 after A doesn’t matter right now.
And “VALUEINPUTOPTION” can have two values, either RAW or USER_ENTERED.
RAW means, the data goes as it is as you can see.
“USER_ENTERED” on the other hand performs operation before sending data to spreadsheet.
For examples, it can calculate the values.
As you can see, it showed addition.
But if you use RAW for same syntax, then it gives you an error, so keep a note.
Lets comment it.

We shall use spreadsheet ID & range again. But range now matters the most when it comes to update.
Lets try some data so that, spreadsheet will start updating from 6th row.
Updating data is vary risky so be careful while executing otherwise it can remove your important data.
Now we put 6 so that it will start operation from 6th row.
As you can see, data is replaced.
But what if we add row number which is empty?
It adds new rows in spreadsheet.
So that is it.
Don’t forget to like, share and subscribe.
Required links are given in the description.
Thanks for watching. 
Please avoid or flag spams/hateful comments. And do not spam. Enjoy :)
------------------------------------------------
How to connect with Google sheet and display data:-
https://youtu.be/CI0xL93Xtpg

Create new Spreadsheet:-
https://developers.google.com/sheets/api/guides/create

Add / Update spreadsheet values:-
https://developers.google.com/sheets/api/guides/values

Subscribe my Channel:-
http://www.youtube.com/user/SanketRooney?sub_confirmation=1

Facebook Page:-
https://www.facebook.com/UnpossibleNS

Twitter Account:-
https://twitter.com/UnpossiblePOG

Blog :-
https://unpossiblepog.blogspot.in/

No comments:

Post a Comment