写入 Google sheet 单元格
Write Google sheet cell
我试图找到如何修改或写入 google sheet 中的单元格。
我通过快速入门指南成功阅读了我的 sheet(在我的驱动器上)(我复制并粘贴了这段代码:https://developers.google.com/sheets/quickstart/ios#step_3_set_up_the_sample)。我刚刚将 url 更改为:
https://sheets.googleapis.com/v4/spreadsheets/my_spreadsheet_Id/values/Feuil1!A1:F
.
但无法找到代码写入我的 sheet... 当我看时:https://developers.google.com/sheets/guides/values#methods。我不明白我应该把我的新数据放在哪里。
示例:我在单元格 A1 上有 "New York"。
我想将 "New York" 更改为 "Tahiti"。
你知道怎么做吗?
我试过了但没有用:
- (void)modifyListe {
NSString *baseUrl = @"https://sheets.googleapis.com/v4/spreadsheets/";
NSString *spreadsheetId = @"{MySpredsheet_ID}"; // choisir la bonne
NSString *range = @"/values/Feuil1!G1:G1?valueInputOption=Tahiti";
baseUrl = [baseUrl stringByAppendingString:spreadsheetId];
baseUrl = [baseUrl stringByAppendingString:range];
[self.service fetchObjectWithURL:[NSURL URLWithString:baseUrl]
objectClass:[GTLObject class]
delegate:self
didFinishSelector:@selector(displayMajorsWithServiceTicketT:finishedWithObject:error:)];
}
解决方案: 看第二 post
我认为找到了解决方案(受此 post 启发):
NSString *baseUrl = @"https://sheets.googleapis.com/v4/spreadsheets/MyspreadsheetID/values/Donnees!G1:G1?valueInputOption=USER_ENTERED";
NSURL *theURL = [NSURL URLWithString:baseUrl];
NSString *rangeKEY = @"range";
NSString *dimensionKEY = @"majorDimension";
NSMutableString *valuesKEY = [NSMutableString stringWithString:@"values"];
NSString *therange = @"Donnees!G1:G1";
NSString *themajorDimension = @"ROWS";
NSMutableString *string_Value = [NSMutableString stringWithString:@"theValue"];
NSMutableArray *ArrayOfString = [NSMutableArray array];
NSMutableArray *arrayOfArray = [NSMutableArray array];
[ArrayOfString addObject:string_Value];
[arrayOfArray addObject:ArrayOfString];
NSMutableDictionary *dicooo = [NSMutableDictionary dictionary];
[dicooo setObject:arrayOfArray forKey:valuesKEY];
[dicooo setObject:therange forKey:rangeKEY];
[dicooo setObject:themajorDimension forKey:dimensionKEY];
GTLObject *theobject ;
theobject = [GTLObject objectWithJSON:dicooo];
[self.service fetchObjectByUpdatingObject:theobject forURL:theURL delegate:self didFinishSelector:@selector(displayMajorsWithServiceTicketT:finishedWithObject:error:)];
当我启动时,我可以在 sheet 上看到修改。
我试图找到如何修改或写入 google sheet 中的单元格。 我通过快速入门指南成功阅读了我的 sheet(在我的驱动器上)(我复制并粘贴了这段代码:https://developers.google.com/sheets/quickstart/ios#step_3_set_up_the_sample)。我刚刚将 url 更改为:
https://sheets.googleapis.com/v4/spreadsheets/my_spreadsheet_Id/values/Feuil1!A1:F
.
但无法找到代码写入我的 sheet... 当我看时:https://developers.google.com/sheets/guides/values#methods。我不明白我应该把我的新数据放在哪里。
示例:我在单元格 A1 上有 "New York"。 我想将 "New York" 更改为 "Tahiti"。
你知道怎么做吗?
我试过了但没有用:
- (void)modifyListe {
NSString *baseUrl = @"https://sheets.googleapis.com/v4/spreadsheets/";
NSString *spreadsheetId = @"{MySpredsheet_ID}"; // choisir la bonne
NSString *range = @"/values/Feuil1!G1:G1?valueInputOption=Tahiti";
baseUrl = [baseUrl stringByAppendingString:spreadsheetId];
baseUrl = [baseUrl stringByAppendingString:range];
[self.service fetchObjectWithURL:[NSURL URLWithString:baseUrl]
objectClass:[GTLObject class]
delegate:self
didFinishSelector:@selector(displayMajorsWithServiceTicketT:finishedWithObject:error:)];
}
解决方案: 看第二 post
我认为找到了解决方案(受此 post 启发):
NSString *baseUrl = @"https://sheets.googleapis.com/v4/spreadsheets/MyspreadsheetID/values/Donnees!G1:G1?valueInputOption=USER_ENTERED";
NSURL *theURL = [NSURL URLWithString:baseUrl];
NSString *rangeKEY = @"range";
NSString *dimensionKEY = @"majorDimension";
NSMutableString *valuesKEY = [NSMutableString stringWithString:@"values"];
NSString *therange = @"Donnees!G1:G1";
NSString *themajorDimension = @"ROWS";
NSMutableString *string_Value = [NSMutableString stringWithString:@"theValue"];
NSMutableArray *ArrayOfString = [NSMutableArray array];
NSMutableArray *arrayOfArray = [NSMutableArray array];
[ArrayOfString addObject:string_Value];
[arrayOfArray addObject:ArrayOfString];
NSMutableDictionary *dicooo = [NSMutableDictionary dictionary];
[dicooo setObject:arrayOfArray forKey:valuesKEY];
[dicooo setObject:therange forKey:rangeKEY];
[dicooo setObject:themajorDimension forKey:dimensionKEY];
GTLObject *theobject ;
theobject = [GTLObject objectWithJSON:dicooo];
[self.service fetchObjectByUpdatingObject:theobject forURL:theURL delegate:self didFinishSelector:@selector(displayMajorsWithServiceTicketT:finishedWithObject:error:)];
当我启动时,我可以在 sheet 上看到修改。