简体   繁体   English

Google电子表格和表格

[英]Google Spreadsheets and sheets

It seems like in the documentation that Google Spreadsheets and Google Sheets both have methods such as getActiveCell() which leads to confusion what the difference between the "Spreadsheet" object and the "Sheet" object. 似乎在文档中,Google Spreadsheets和Google Sheets都具有诸如getActiveCell()方法,这使“ Spreadsheet”对象和“ Sheet”对象之间的区别产生了混淆。 I assume that a spreadsheet is a collection of sheets. 我假设电子表格是工作表的集合。 Suppose that I want to open a file with the following code where my Spreadsheet only has 1 sheet (see question in commented lines and assume I want to then do operations on the first sheet of both files): 假设我要使用以下代码打开一个文件,其中我的电子表格只有一张工作表(请参见注释行中的问题,并假设我要在两个文件的第一张纸上进行操作):

function OpenFile(FileName) {
  var FileToGetIterator = DriveApp.getFilesByName(FileName);
  var FileToGet = FileToGetIterator.next();
  var SpreadSheets = SpreadsheetApp.open(FileToGet);
  var SpreadSheet1 = SpreadSheets.getSheets()[0]; // is this line necessary??
}

Similarly for creating a file 同样用于创建文件

function CreateFile(SpreadSheetName) {
  var NewSpreadSheets = SpreadsheetApp.Create(SpreadSheetName); 
  var NewSpreadSheet = NewSpreadSheets.getSheets()[0]; // is this line necessary?
}

when you create a spreadsheet or you open a spreadsheet it automatically open the first sheet of the spreadsheet,so no it's not necessary. 创建电子表格或打开电子表格时,它会自动打开电子表格的第一张纸,因此没有必要。 nevertheless the opened sheet is opened as the "activesheet" and you've got less methods than if you specifically open a particular sheet with your method 但是,已打开的工作表将作为“活动工作表”打开,与使用方法专门打开特定工作表相比,您拥有的方法更少

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

相关问题 从Google电子表格文档中获取工作表名称 - Get sheets names from google spreadsheets docs 在Google电子表格上使用表格插入行 - insert rows using sheets on google spreadsheets Google 电子表格中工作表之间的一对多报告 - one-to-many reporting between sheets in Google Spreadsheets 谷歌表格脚本,从不同的电子表格中获取和设置数据 - google sheets script, get and set data from different spreadsheets 在四张纸上隐藏除今天以外的所有列(Google Spreadsheets脚本) - Hide all but today's columns on four sheets (Google Spreadsheets script) 将 Google 电子表格 API V4 (spreadsheets.values.get) 与 Private Sheets 连接起来 - Connect Google Spreadsheets API V4 (spreadsheets.values.get) with Private Sheets Google表格在单独的电子表格之间移动行不起作用,但表格之间却行 - Google Sheets moving rows between separate spreadsheets not working but between sheets is working Google App Scripts & Google Sheets - 相当于 VLOOKUP/IMPORTRANGE - 使用多个电子表格 - Google App Scripts & Google Sheets - Equivalent of VLOOKUP/IMPORTRANGE - Using multiple spreadsheets 如何使用Google表格API spreadsheets.values.get返回读取的值? - How to return values read using Google Sheets API spreadsheets.values.get? 删除多个电子表格中的多个工作表 - Deleting multiple sheets in multiple spreadsheets
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM