简体   繁体   English

无法从Google Apps脚本的多个工作表中获取范围

[英]Cannot get ranges from multiple sheets in google apps script

I'm trying to run a short section of my code that gets 2 ranges off of one spreadsheet, 1 range off of another, and create a new sheet. 我正在尝试运行我的代码的一小段内容,即从一个电子表格中缩小2个范围,从另一个电子表格中缩小1个范围,然后创建一个新工作表。 The code I am using is as follows: 我使用的代码如下:

var names = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Availability").getRange(2, 2, 19, 1);
var availability = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Availability").getRange(2, 2, 19, 6);
var needs = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Needs").getDataRange();
var staffingSheet = SpreadsheetApp.getActiveSpreadsheet().insertSheet("Staffing");

When I change the order of the first three lines I get errors on different lines and different calls but they are all TypeError: Cannot read property "0.0" from undefined. 当我更改前三行的顺序时,在不同的行和不同的调用上会出现错误,但它们都是TypeError: Cannot read property "0.0" from undefined. Oddly enough, when the staffingSheet already exists, no errors are thrown by the first three lines but an error is caused by the existance of the sheet its trying to create. 奇怪的是,当staffingSheet已经存在时,前三行不会引发任何错误,但是由于尝试创建的工作表的存在而导致了错误。 Anyone have any ideas? 有人有想法么?

Redian resolved it. Redian解决了它。 There were no errors, the problem was in other code section. 没有错误,问题出在其他代码部分。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 有没有办法将 onEdit function 应用于谷歌表格应用程序脚本中的多个单独范围? - Is there a way to apply an onEdit function to multiple separate ranges in google sheets Apps Script? 在Google Apps脚本中定义多个范围 - Define multiple ranges in Google Apps Script Google Sheets Apps 脚本——来自多行单元格的 select 值 - Google Sheets Apps Script -- select value from cell with multiple lines 如何将 Google Apps 脚本应用于多个工作表 - How to apply Google Apps Script to multiple sheets Google Apps Script - 如何将此代码应用于 Google 表格中的多个表格 - Google Apps Script - how to applies this code for multiple sheets in google sheets Google Apps Script - 按标签颜色获取工作表 - Google Apps Script - Get sheets by tab color 如何在Google Apps脚本中为Google电子表格创建具有多个范围的图表 - How to create a chart with multiple ranges in google apps script for google spreadsheets 从 Apps 脚本显示消息 Google 表格 - Display message Google Sheets from Apps Script 从 Google 表格中的单元格和范围检索到 Apps 脚本后,统一日期格式的最佳方法是什么? - What's the best way to unify date formats after retrieving them from cells and ranges in Google Sheets to Apps Script? 无法使用 Google Apps 脚本访问 Google 表格中的持续时间值 - Cannot Access Duration Value in Google Sheets with Google Apps Script
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM