编写Google表格单元格 [英] Write Google sheet cell
问题描述
我尝试找到如何在Google表格中修改或编写单元格. 我成功阅读了快速入门指南(在驱动器上)(我已经复制并粘贴了以下代码:
I try to find how modify or write a cell in a google sheet. I success to read my sheet (on my drive) with quickstart guide (I had copied and pasted this code : https://developers.google.com/sheets/quickstart/ios#step_3_set_up_the_sample). I had just changed the url by :
https://sheets.googleapis.com/v4/spreadsheets/my_spreadsheet_Id/values/Feuil1!A1:F
.
But impossible to find a code to write on cells of my sheet... when i look : https://developers.google.com/sheets/guides/values#methods. I don't understand where i should put my new data to the cell.
示例:我在单元格A1上显示纽约". 我想将大溪地"更改为纽约".
Exemple : i have "New York" on the cell A1. i want to change "New York" by "Tahiti".
你知道怎么做吗?
我尝试了这个但没有用:
i tried this but not working :
- (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:)];
}
解决方案::查看第二篇文章
推荐答案
I think found the solution (inspired by this 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:)];
启动时,我可以在工作表上看到修改.
When I launch I can see the modification on my sheet.
这篇关于编写Google表格单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!