google-apps-script - 编程以通过在工作表中选择某人的姓名将 Google 工作表添加到某人的云端硬盘
问题描述
当我从我是销售代表的人员列表中选择时,我正在尝试创建一个工作系统,并在副本上填写表格。
只是看看是否还有一种方法,当我选择我的名字时,它也会将该表添加到我自己的驱动器中。
解决方案
你不是很清楚你想要什么,但这种脚本可能是你要找的。如果没有,对不起。
function saveSelected() {
var ss=SpreadsheetApp.getActive();
var sh=ss.getSheetByName('Employee List');
var data=sh.getRange(sh.getActiveCell().getRow(),1,1,sh.getLastColumn()).getValues()[0];
var sObj={name:data[0],ssId:data[1],driveId:data[2]};
var folder=DriveApp.getFolderById(sObj.driveId);
var file=DriveApp.getFileById(sObj.ssId);
file.makeCopy(folder);
}
function loadSideBarButton() {
var userInterface=HtmlService.createHtmlOutput('<input type="button" value="Save Selected Row" onClick="google.script.run.saveSelected()" />');
SpreadsheetApp.getUi().showSidebar(userInterface);
}
function onOpen() {
loadSideBarButton();//When you click this button saveSelected will be called and it will save the spreadsheet for the employee that you have selected with your cursor. You just have to have selected the correct row.
}
上述脚本适用于以下数据结构。
当然,您必须获得对员工文件夹的完全访问权限。
推荐阅读
- macports - 来自 MacPorts 的 Gnuradio Companion 3.8.2 未在 Catalina 中启动石英
- r - 如何在 purrr:map 函数中循环 lm 函数参数
- sql - 选择最近的时间戳行并从具有 Variant DataType 的列中获取值
- javascript - 使用先前存储在数据库中的凭据执行发送电子邮件的 API 端点。(使用 Gmail REST API)
- list - 如何找到列表中的字符串是另一个列表中另一个字符串的子字符串的次数?
- html - 如何将 4 个元素 2 x 2 弯曲包装
- flutter - 从字段中检索 Firestore 自动生成的文档 ID
- dialogflow-es - 为什么dialogflow不能识别CNY?
- amazon-web-services - AWS EMR - 在主实例应用程序预置失败时因错误而终止
- python - 如何丢弃函数参数中的无值