脚本复制格式不再工作 [英] Script To Copy Format No Longer Working

查看:59
本文介绍了脚本复制格式不再工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一张Google表格,可以从另一张表格中粘贴整行。然后我运行一个脚本来完成一些事情,包括复制上述行的格式(以便将验证和日期格式添加到新行中)。



我总是这样做:

  templateRange.copyTo(targetRange,{formatOnly:true})

在我的定义中, templateRange 是:

  var templateRange = SpreadsheetApp.getActiveSpreadsheet()。getActiveSheet()。getRange(rowAbove,1,1,36)

targetRange 是:

  var targetRange = SpreadsheetApp.getActiveSpreadsheet()。getActiveSheet()。getRange(rowNumber,1,1,36)

这种方法在数月内完美运作。甚至几年。



但是最近 - 脚本没有任何改动 - 它停止工作。



任何人有什么想法出了什么问题?

好的。我解决了我自己的问题。用 formatOnly:true 发现 copyTo 仍然正常工作。但是,该功能显然不再复制数据验证或日期。为此,我需要使用DataValidation类。日期同样的故事。膝盖疼痛。但至少我让脚本再次运行。


I have a Google Sheet that I paste entire rows into from a different sheet. I then run a script that does a couple of things, including copying the format of the row above (so that the validation and date formats are added to the new row).

I've always done this with:

templateRange.copyTo(targetRange, {formatOnly:true})

In my definitions, templateRange is:

var templateRange = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().getRange(rowAbove, 1, 1, 36)

And targetRange is:

 var targetRange = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().getRange(rowNumber, 1, 1, 36)

This approach has worked flawlessly for months. Even years.

But recently--with NO changes to the script--it's stopped working.

Anybody have any ideas what's gone wrong?

解决方案

OK. I've solved my own problem. Turns out copyTo with formatOnly:true is still working fine. But that function is apparently no longer copying data validation or dates. To do that, I needed to use the DataValidation Class. Same story for the date. Pain in the knee. But at least I got my script operational again.

这篇关于脚本复制格式不再工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆