[英]set a table in a specific sheet of Google Sheets
I have the following code that adds a table in google sheets form the data based on the URL in the code.我有以下代码,它根据代码中的 URL 在谷歌表格中添加一个表格。 The current code creates tables in the currently active sheet.
当前代码在当前活动工作表中创建表格。 but from the variable "response3", I need to create a table in a particular sheet, not the active one.
但是从变量“response3”中,我需要在特定工作表中创建一个表,而不是活动表。 Exactly, I need a create a table from response3 in the sheet called "sheet3".
确切地说,我需要从名为“sheet3”的工作表中的 response3 创建一个表。
Here is my code:这是我的代码:
var response3 = UrlFetchApp.fetch("https://tabulation.dooblo.net/dAPI/Tabulation/GetSurveyTabulationData?ticket=ebc02621-579b-43ed-ab78-001383a46169&variable=Q_3",params);
Logger.log(response3.getContentText());
var csvData3 = Utilities.parseCsv(response3);
var sheet3 = SpreadsheetApp.getActiveSheet();
sheet3.getRange(1, 8, csvData3.length, csvData3[0].length).setValues(csvData3);
}
I tryied with next code but did not work:我尝试了下一个代码,但没有奏效:
var response3 = UrlFetchApp.fetch("https://tabulation.dooblo.net/dAPI/Tabulation/GetSurveyTabulationData?ticket=ebc02621-579b-43ed-ab78-001383a46169&variable=Q_3",params);
Logger.log(response3.getContentText());
var csvData3 = Utilities.parseCsv(response3);
var sheet3 = SpreadsheetApp.getActiveSheet().getSheetByName("sheet3");
sheet3.getRange(1, 8, csvData3.length, csvData3[0].length).setValues(csvData3);
Anyone could help me with it?任何人都可以帮助我吗?
Thanks so much in advance,提前非常感谢,
getActiveSheet()
or getSheetByName()
- not bothgetActiveSheet()
或getSheetByName()
- 不是两者What you probably try to do is to get a sheet by name on the active spreadsheet ,您可能尝试做的是在活动电子表格上按名称获取工作表,
so:所以:
var sheet3 = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("sheet3");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.