我有一张包含6张纸的日常工作表,但只有前4张我需要在他们运行备份存档之前输入日期,因此在单元格A1中添加了今天的日期。所有每日工作表都有今天的日期和日期,即星期五08.09.17作为标题,但它们可以提前几个月制作,所以当进行备份(已经工作)时,我需要今天的日期在单元格A1中所有4张所以它们被移动更正日期的归档表,这是备份脚本用于放入归档表日期列的内容,以便我们可以跟踪客户的日常使用情况。 我正在使用此脚本,但得到一个空白输出: -
function timeStamp() {
SpreadsheetApp.getActiveSheet()
var sheetNames = ['1st sheet name', '2nd sheet name', '3rd sheet name',
'4th sheet name'];
.setActiveCell(A1));
.setValue(new Date());
答案 0 :(得分:0)
假设您想要的图纸位于同一个电子表格中,那么您只需要转到A1并输入=nameOfSpreadsheet()
是的,我知道按惯例将所有图片都大写信件,但我通常游泳下面的风俗潮流。如果您愿意,您可以将所有这些都大写。
function nameOfSpreadsheet()
{
return SpreadsheetApp.getActive().getName();
}
当然,您还必须将该功能放入脚本编辑器中的项目中。我将这样的自定义函数保存在与其他函数不同的项目中。
答案 1 :(得分:0)
我无法在评论中回答保罗的问题,所以我们走了。
不确定这是否是最终的解决方案,但是......
function timeStamp() {
var sheetNames = ['1st sheet name', '2nd sheet name', '3rd sheet name','4th sheet name'];
for(i=0;i<sheetNames.length;i++)
SpreadsheetApp.getActive().getSheetByName(sheetNames[i]).getRange("A1").setValue(new Date())
}
一点解释..
SpreadsheetApp
应用程序“Google SpreadSheets”的实例
SpreadsheetApp.getActive()
这将返回活动的SpreadSheet(如工作簿/完整文档),也可以使用.getActiveSpreadSheet()
和
SpreadsheetApp.getActive().getSheetByName(sheetNames[i])
这将返回名称为sheetNames[i]
的工作表(相对于工作表/选项卡)
.getRange("A1").setValue(new Date())
为相应的工作表
只考虑你拥有的东西
以下将起作用
//You can drop the semicolon here if you want.
var sheetNames = ['1st sheet name', '2nd sheet name', '3rd sheet name', '4th sheet name'];
//Moved it one line down as the next two lines run off of it by referencing it with a .(well almost)
SpreadsheetApp.getActiveSheet()
//If line above is array assignment then no matter what you do you will get syntax error for the below two lines.
// You need to pass the address as string, unless A1 is a variable with string address.
.getActiveCell("A1")
//Note that for this to work there should be no semicolons for the two lines of code above this.
.setValue(new Date())
//Semicolon marks the end of statement and thus losing reference to an object and making any .function calls syntax errors