小编Kas*_*und的帖子

将谷歌应用程序脚本移动到 v8 文件上传停止从侧边栏工作

我在 Google 电子表格中有一个 HTML 侧边栏,其中包含一个不适用于新 v8 引擎的文件上传输入字段。它确实适用于旧的 runtimeVersion DEPRECATED_ES5。

侧边栏中的文件上传用于将单个文件上传到我的谷歌驱动器。

html文件

<body>
<h1>File Uploader</h1>
<form>
    <input type="file" name="myFile" id="file">
    <br>
    <input class="blue" type="button" id="submitBtn" value="Upload File" onclick="uploadthis(this.parentNode)">
    
</form>

<input type="button" value="Close" onclick="google.script.host.close()" />

<script>
  
function uploadthis(fileForm){

google.script.run
.uploadFiles(fileForm)
}


   
</script>
    
</body>
Run Code Online (Sandbox Code Playgroud)

这里是简化的 gs

function uploadContract() {
  var html = HtmlService.createHtmlOutputFromFile('ContractUpload').setTitle('Kontrakt upload').setWidth(300);
SpreadsheetApp.getUi().showSidebar(html);
}

function uploadFiles(data){
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sStamdata = ss.getSheetByName('Stamdata_New');
var contractFolderId = sStamdata.getRange('D60').getValue(); 
var idag = Utilities.formatDate(new Date(), "GMT+1", "yyyyMMdd");
var title = sStamdata.getRange('D52').getValue(); …
Run Code Online (Sandbox Code Playgroud)

v8 file-upload web-applications google-sheets google-apps-script

4
推荐指数
1
解决办法
1415
查看次数

如何从带有占位符的模板创建新文档

我正在尝试创建一个脚本,该脚本将从模板文档创建新文档。根据特定列中的关键字搜索,将文档中的占位符替换为工作表中的数据。然后更改特定列中的行值,以便在脚本再次运行时不会处理该行。

我认为我已经正确地完成了第一个关键字搜索和行的循环。但将数据“合并”到占位符的最后一部分我不知道如何做。我只是获取值“object Object”和文档中的其他值。

var ss = SpreadsheetApp.getActiveSpreadsheet();
var s = ss.getActiveSheet();
var lastColumn = s.getLastColumn();
function createDocFromSheet() {
  var headers = getUpsertHeaders(s);//function is defined outside of this function

  var statusColNum = headers.indexOf('Status')+1;

  var row = getRowsData(s); //The function is defined outside this function.
  for (var i=0; i<row.length; i++) {
     var jobStatus = '';
     if (row[i]['Status'] === '') {

//New: write the status to the correct row and column - this will be moved to the end when I get the …
Run Code Online (Sandbox Code Playgroud)

google-sheets google-apps-script

3
推荐指数
1
解决办法
5817
查看次数

Google日历与Google电子表格同步

我发现了这个非常棒的脚本,可以同步Google Cal和Google电子表格。双向同步。而且有效!-> https://github.com/Davepar/gcalendarsync

现在,我无法将日历的地址放在名为Data的工作表中。在单元格B1中。脚本应该从那里拉地址,这样我就不需要在脚本中更改它。

有人可以弄清楚该怎么做吗?
更改将涉及通过Data!B1来定义calendarId
并且脚本应仅在工作表上运行

您可以在此处查看示例文档:https : //docs.google.com/spreadsheets/d/1TCIIBRmshx2kmhhwrhCpg5sxO7N82tOJ7hHxWv_u-Yw/edit? usp =sharing

我在工作表脚本上复制了脚本

google-calendar-api google-sheets google-apps-script

-2
推荐指数
1
解决办法
2893
查看次数