I'm trying to save from my script to google sheet, but it seems to override the same cells over and over again, I think its about the "range"? I tried to put there - "Patients!A1:C" as I saw in some codes but its not working.
How I can save to new row?
static string spreadsheetID = "myspredshete";
static string path = "mypath.";
static SheetsService sheetsService;
public static RequestTest Instance;
List<string> strings; //all A1:A35 first lines in the
string currentRangeName;
int rowsPerIterration = 10;
void Start()
{
Debug.LogError("Google Sheets Master performs start");
if (Instance != null && Instance != this)
{
Destroy(gameObject);
return;
}
Instance = this;
DontDestroyOnLoad(gameObject);
SetUpCredentials();
Invoke("PrintCell",2);
//Invoke("LogPlayerTersting", 2);
//LogPlayer(); // not sure we should
}
void SetUpCredentials() //this must also be done async
{
string fullPath = Application.dataPath + path;
Stream creds = File.Open(fullPath, FileMode.Open);
ServiceAccountCredential serviceAccountCredential = ServiceAccountCredential.FromServiceAccountData(creds);
sheetsService = new SheetsService(new BaseClientService.Initializer() { HttpClientInitializer = serviceAccountCredential });
}
public void LogPlayer(string patientName,string patientJson, string treatmentJson)
{
var valueRange = new Google.Apis.Sheets.v4.Data.ValueRange();
var objectList = new List<System.Object>{patientName,patientJson,treatmentJson};
valueRange.Values = new List<IList<object>> { objectList };// // List<System.object> Objects to save in order of columns
var updateRequest = sheetsService.Spreadsheets.Values.Update(valueRange, spreadsheetID, "A1:C1");
updateRequest.ValueInputOption = SpreadsheetsResource.ValuesResource.UpdateRequest.ValueInputOptionEnum.USERENTERED;
// var updateResponse = updateRequest.ExecuteAsync();
var updateResponse = updateRequest.Execute();
Debug.Log(updateResponse);
}
I tried to create new var as
string range = "Patients!A1:C1";
but that didn't work.