Google Sheets, update just one cell?

50 views
Skip to first unread message

CC

unread,
Apr 19, 2019, 9:00:10 PM4/19/19
to MIT App Inventor Forum
Hi,
I am successfully reading from a google sheets and writing to another google sheets. However, I would like to edit the sheet I wrote to, so changing one cell of an existing record. I don't know how to write a script. I am writing to the google sheet by using Web1.writing.URL to a modified URL. Is there a way to change one cell's value? 

Thank you.

TimAI2

unread,
Apr 20, 2019, 6:04:28 AM4/20/19
to MIT App Inventor Forum
Use a google web app to achieve this:


This will currently only change the content of cell A1 on a separate tab, you can use this and link to your preferred cell, or write more code to change a specific cell

CC

unread,
Apr 20, 2019, 7:33:27 PM4/20/19
to MIT App Inventor Forum
Is that the only way? There really isn't a way to update a google sheet from App Inventor without the use of a web app?


TimAI2

unread,
Apr 20, 2019, 8:08:08 PM4/20/19
to MIT App Inventor Forum
Of course there are other ways :)

The web app method will allow you to do this whether your google sheet is private or public (view/access by anyone with the link).

If your sheet is public you can try Taifun's database method: HERE

TimAI2

unread,
Apr 20, 2019, 8:14:43 PM4/20/19
to MIT App Inventor Forum
You could also download the whole sheet (csv), edit the cell on the app, then upload the csv content back to the sheet (using a web app!!)

CC

unread,
Apr 20, 2019, 8:50:41 PM4/20/19
to MIT App Inventor Forum
Hi TimAI2,
The sheet is public but does that mean I need to use an outside database method? I am using PostText now. Is there another command I should use instead? I don't know if I am allowed to use other people's scripts. Thank you...

CC

unread,
Apr 20, 2019, 8:56:47 PM4/20/19
to MIT App Inventor Forum
TimAI2,
I sort of followed Taifun's directions. My blocks look very similar to his. However, after I read in the last column, he calls getAction, which for an update just says UPDATE. So I tried to add another block and say UPDATE (in case that's what I'm missing) but then my last column just says UPDATE. Then I see further down the page that his SQL query is:

UPDATE spreadsheet SET email="my updated email", message="let's update" WHERE name="Taifun2"


I get this feeling I am missing some words like maybe the UPDATE part but I don't know how to word it or where to add it and I am just guessing. If you can point me to where the documentation is for how to update without a script? Thank you...




TimAI2

unread,
Apr 21, 2019, 5:27:34 AM4/21/19
to mitappinv...@googlegroups.com
Three things:

1. Your question, I believe, should have been: "How do i update any one cell in Google Sheets?" instead of "just one cell"  Yes?
2. I have never used Taifun's method, my preference is to work with Google Web Apps. Hopefully Taifun can help out here.
3. You might want to look at my CRUD method: HOWTO: AI2 - Google Sheets - Web App - Create/Read/Update/Delete, as an alternative


CC

unread,
Apr 21, 2019, 10:42:55 AM4/21/19
to MIT App Inventor Forum
Hi TimAI2,
I don't know how to use scripts or add them in and want to try it without them for right now. You mentioned that there was another method to do an update:

"You could also download the whole sheet (csv), edit the cell on the app, then upload the csv content back to the sheet (using a web app!!)"

To try this method, would I use Web1.Get? The times I have used Web1.Get it adds a row onto the bottom of Sheets. What command would I use to read in a whole sheet, modify some values in the csv, then write the csv back to the sheet as a replacement of what I read in?

Thank you!!

CC

unread,
Apr 21, 2019, 10:44:06 AM4/21/19
to MIT App Inventor Forum
To clarify:

I know how to read in a whole sheet and modify values. What I don't know how to do is how to write the sheet back to replace what exists. 

Thank you!

TimAI2

unread,
Apr 21, 2019, 1:30:58 PM4/21/19
to mitappinv...@googlegroups.com
Unfortunately for you, as mentioned, a web app is required ;)


To overwrite the existing data with new data, you need to add a "sheet.clearContents();" to the script before writing the new data.


Reply all
Reply to author
Forward
0 new messages