[英]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.