Here是我的项目
我有一个简单的谷歌形式供教师观察,我想使用由每个表单提交触发的脚本自动换行格式化单元格。
function triggerWrap() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var s = ss.getSheetByName('Form Responses 1');
var r = s.getDataRange();
r.setWrap(true)
}
function myFunction(e) {
e.range.setWrap(true);
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
var cell = sheet.getRange('B1:O300');
cell.setWrap(true)
var Time = e.values[2];
var TeacherName = e.values[1];
var Date = e.values[3];
var Goal1 = e.values[4];
var Goal1Domains = e.values[5];
var Goal1Teacher = e.values[6];
var Goal1Student = e.values[7];
var Goal1Suggestions = e.values[8];
var Goal2 = e.values[9];
var Goal2Domains = e.values[10];
var Goal2Teacher = e.values[11];
var Goal2Student = e.values[12];
var Goal2Suggestions = e.values[13];
var subject = "Informal Observation Notes for your Records";
var message = "Hello,\n" + "Here are the notes from our informal observation:" + "\n\nDate: " + Date + "\n\nTime: " + Time + "\n\nGoal 1: " + Goal1 + "\n\nDomain(s): " + Goal1Domains + "\n\nObserved Teacher Behaviors: " + Goal1Teacher + "\n\nObserved Student Behaviors: " + Goal1Student + "\n\nSuggestions: " + Goal1Suggestions;
MailApp.sendEmail (<******>, subject, message);
}
正如您所看到的,我已经尝试了一些方法(在我的电子邮件通知功能中,一次作为单独的功能和两种不同的方式),但只有顶行正在进行格式化。我试过上下移动灰线,没效果。
最奇怪的部分:如果你点击任何一个单元格并手动格式化它们,它就说它已经设置为自动换行。我还尝试将所有单元格设置为溢出,然后再次运行脚本。
有什么想法吗?
答案 0 :(得分:0)
你需要做一些事情。您需要将函数名称更改为onFormSubmit。另外,通过参考资料设置一个可安装的onChange触发器。在测试数据中,您需要在每个单元格中为文本添加空格。这是一个已知问题(问题6016)。我还建议您在代码中添加垂直对齐顶部。试试这个:
function onFormSubmit(e){
var ss = SpreadsheetApp.getActiveSpreadsheet();
var s = ss.getSheetByName('Form Responses 1');
var r = s.getDataRange();
r.setWrap(true).setVerticalAlignment("top")
}