如何使用C#而不是其他客户端脚本使用命名范围从谷歌电子表格中读取范围?
此代码包含用于插入电子表格的逻辑。这里列表盲目插入谷歌表。但是我想根据google sheet中的命名范围插入它,并且需要插入列的命名范围。
SheetsService SheetsService = GetSheetsService();
string newRange = "WORKORDERTYPE";
var namedRanges = SpreadsheetApp.getActiveSpreadsheet().getNamedRanges();
var StrReportJson = JsonConvert.SerializeObject(list);
JArray arrayJson = JArray.Parse(StrReportJson);
List<IList<Object>> objNewRecords = new List<IList<Object>>();
for (int i = 0; i < arrayJson.Count; i++)
{
IList<Object> obj = new List<Object>();
JObject SingleObj = JObject.Parse(arrayJson[i].ToString());
foreach (var pair in SingleObj)
{
if(pair.Key.ToUpper()=="WORKORDERTYPE")
obj.Add(pair.Value);
}
objNewRecords.Add(obj);
}
SpreadsheetsResource.ValuesResource.AppendRequest request = SheetsService.Spreadsheets.Values.Append((new ValueRange() { Values = objNewRecords }, SpreadSheetID, newRange);
request.InsertDataOption=SpreadsheetsResource.ValuesResource.AppendRequest.InsertDataOptionEnum.INSERTROWS;
request.ValueInputOption=SpreadsheetsResource.ValuesResource.AppendRequest.ValueInputOptionEnum.USERENTERED;
var response = request.Execute();