我试图找到如何修改或写入Google工作表中的单元格。 我成功地使用快速入门指南阅读了我的工作表(在我的驱动器上)(我复制并粘贴了这段代码:https://developers.google.com/sheets/quickstart/ios#step_3_set_up_the_sample)。我刚刚更改了网址:
https://sheets.googleapis.com/v4/spreadsheets/my_spreadsheet_Id/values/Feuil1!A1:F
但我找不到代码来写我的表格的单元格...当我看起来:https://developers.google.com/sheets/guides/values#methods。我不明白我应该把新数据放到单元格中。
例如:我有"纽约"在单元格A1上。 我想改变"纽约" by" 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:)];
}
解决方案:查看第二篇文章
答案 0 :(得分:1)
我认为找到了解决方案(受此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:)];
当我启动时,我可以在我的工作表上看到修改。