简体   繁体   English

在特定的 Google 表格中设置表格

[英]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,提前非常感谢,

It is either the getActiveSheet() or getSheetByName() - not both它是getActiveSheet()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.

相关问题 谷歌工作表中特定工作表的时间戳 - Timestamp to specific sheet in google sheets 激活Google表格中的特定表格 - Activate a specific sheet in a Google Sheets book 链接到嵌入式Google表格中的特定表格 - Link to specific sheet in embedded Google Sheets 仅在特定工作表上使用脚本,而不是在 Google 工作表中的所有工作表上使用脚本 - Use script only on specific sheet not on all sheets in Google sheets 在google工作表的google脚本中的特定工作表上使用onedit()触发器 - use onedit() trigger on a specific sheet within google scripts for google sheets 选择特定工作表时触发宏 - Google Sheets - Triggering a macro when a specific sheet is selected - Google Sheets 谷歌表格 - 根据特定列将行移动到另一张表格 - Google Sheets - Moving row to another sheet based on specific column 如何将特定工作表的 URL 插入 Google 表格中的单元格 - How to insert the URL for the specific sheet into a cell in a Google Sheets Google 表格 - 根据电子表格中的特定表格发送电子邮件 - Google Sheets - Sending email based on specific sheet in a spreadsheet 如果Google工作表宏中的特定工作表为空,则隐藏或过滤行或列 - Hide or filter rows or columns if specific sheets are empty in a google sheet macro
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM