Adding row in Google Spreadsheet


#1

Hi all,

How do we add row to the Google Spreadsheet using AppStudio?

Thanks in advance.


#2

Here is the documentation that we have on this:
http://wiki.nsbasic.com/Google_Drive_API#Reading_and_Writing_Spreadsheets

George Henne
NS BASIC Corporation
http://www.nsbasic.com


#3

Thanks George,

I am aware of the documentation and I am referring to this when crating a test app. I created a spreadsheet with 3 columns and 5 rows and I add 3 TextBoxes, TextBox1, TextBox2 and TextBox3 and add a button Add.

I have no problem with editing and saving for all t he 5 rows, however when I wanted to add the six rows, I got the following error message.

TypeError: undefined is not an object (evaluating ‘spreadsheet[nrow][0] = TextBox1.value’).
line 116 column 23

This is the function for adding the row: here nrow = 5

function Button_add_onclick()
spreadsheet[nrow][0] = TextBox1.value
spreadsheet[nrow][1] = TextBox2.value
spreadsheet[nrow][2] = TextBox3.value
GoogleDrive.saveSpreadsheet(spreadsheet, FILE_ID, saveSpreadsheetCallback)
End function

Any suggestion what went wrong?


#4

I think this issue here is “How do I add a row to an array” - Google Spreadsheet is not part of the issue.

Have a look at the Push command:

http://wiki.nsbasic.com/Push

George Henne
NS BASIC Corporation
http://www.nsbasic.com


#5

Error resolved. Thanks George. Now the function is:

function Button_add_onclick()
Push(spreadsheet,[TextBox1.value,TextBox2.value,TextBox3.value])
GoogleDrive.saveSpreadsheet(spreadsheet, FILE_ID, saveSpreadsheetCallback)
End function


#6

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.