google-apps-script - Create Google Apps Script file with DriveApp
问题描述
Code to create an appscript file using appscript editor. for example you type this:
function msWordExt() {
var ss = SpreadsheetApp.openById('1MUwH0Cm1cwHcTWSCGPp2SePbzs_4QQmtjwOEWOrOkMw');
var sheetName = ss.getSheetByName("Sheet2");
var get = sheetName.getRange(2,3).getValue();
var folder = DriveApp.getFolderById("1rsicZccurujGp5Ye5HUecBIAPf3_h5Pc");
folder.createFile("PLAIN TEXT",get,MimeType.MICROSOFT_WORD);}
So the above code creates a MS Word extension file inside a persons Google Drive.
Now I want to try creating a google appscript file extension using code as well, for example the below code doesn't work but it will help give the gist of what I wish to accomplish:
function appScript() {
var ss = SpreadsheetApp.openById('1MUwH0Cm1cwHcTWSCGPp2SePbzs_4QQmtjwOEWOrOkMw');
var sheetName = ss.getSheetByName("Sheet2");
var get = sheetName.getRange(2,3).getValue();
var folder = DriveApp.getFolderById("1rsicZccurujGp5Ye5HUecBIAPf3_h5Pc");
folder.createFile("This is an appscript file",get,MimeType.GOOGLE_APPS_SCRIPTS);
}
解决方案
Considerations
You can't use the Drive API to create a Google Apps Scripts Project. Here you can see it's already been reported to Google.
Proposed workaround
You can use the Apps Script API to manage your Apps Script projects. Here is a link to the guide: https://developers.google.com/apps-script/api/samples/manage
Reference
推荐阅读
- rest - 用于图像文件名的 SHA-1,仍然安全吗?
- python - Python import class from module 说找不到模块错误
- python - AttributeError:模块“matplotlib.pyplot”没有属性“pyplot”
- javascript - 如何在Javascript中按值对数组中的嵌套字典进行排序
- maven - 将 Maven 项目迁移到 Gradle 的问题
- python - Python,如何对多元时间序列进行聚类?
- swift - 标题视图未扩展到 safeArea SwiftUI
- angular - 从 FireStore GET 订阅刷新数据 - Angular - Firebase/FireStore
- html - 从 URL 源创建 html 表
- python - 一个对象如何影响同一类的另一个对象?