Sometimes you may need to collect data from players. This could be their scores, game statistics, feedback, survey answers or anything else. There are many ways...
Hi dop2000
How do I simply upload all the values of an array to a google spreadsheet ?
You can send a long string of values (an entire array if you wish) in the AJAX request, but you'll have to edit the Google Apps Script. It will need to parse that string and write all values correctly into the spreadsheet.
Oh! I'm afraid I haven't the faintest idea on how to do this. Could you please provide some advice about this ?
You can add all values from the array into a string, for example comma-separated. And send that string with AJAX request, say with "data" tag. Then you need to parse that string in the script and write each value into a new cell on the spreadsheet. It could look something like this:
pastebin.com/raw/k03h0i09
(Please note that I haven't tested it)
Thank you ! I have to admit I'm not familiar at all with this syntax and have a little trouble to understand what to do.
Actually, my app already has an array to csv export system (this one actually howtoconstructdemos.com/export-array-data-to-csv-excel-file-format-c3p/) so maybe this string named 's' can be sent to spreadsheet.
Two questions :
- Does the spread sheet adapts itself to the number of lines my array has or do I have to specify it somewhere ? (my array grows and grows through time)
- Do we have to give a name to every spreadsheet column or is it possible to refer to them in the script with their rank (starting from 0) like we do in arrays in C3 ? My array has 100 columns .
Is your array 1D or 2D? The example I posted above should parse 1D array and put all values in a new row on the spreadsheet, each value in its own column. Say, if you are sending this string: "apple,banana,plum,100,200"
Then "apple" will be in column A and "200" in column E.
My array is 2D. Thank you, I get it from your exemple.
How do I tell when values are to be stored in line 2, 3, etc ?
I read on your wonderful website that you offered free casual help (that's what you are doing now and I'm very grateful) but that you can also solve a problem for a fee. I don't have much for this project but can offer some money. The project here is to help my father track is health condition (he has Parkinson).
removed