使Google Apps脚本在移动设备上运行 [英] Getting Google Apps Scripts to Run on Mobile

查看:92
本文介绍了使Google Apps脚本在移动设备上运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试获取为Google工作表创建的脚本,以便在工作表打开时触发(因为我发现您无法通过移动应用手动触发它们).不知何故,我设法使一半的脚本可以工作,而另一半则没有.该脚本旨在在台式机和移动设备上使用,我希望它清除一组预定的单元格范围,同时还隐藏一组预定的行和列(用于格式化).该脚本可以在桌面上完美运行,但是即使脚本的hideRows/Columns部分可以运行,脚本的clearRanges部分也不能在移动设备上运行.关于这可能是什么的任何想法?我正在使用的功能如下所示:

I'm trying to get a script that I've made for a google sheet to trigger when the sheet is opened (since I've found you can't trigger them manually through the mobile app). Somehow, I've managed to get half the script to work, while the other half does not. The script is intended for use on both desktop and mobile, and I want it to clear a predetermined set of cell ranges while also hiding a predetermined set of rows and columns (for formatting purposes). The script runs perfectly on desktop, but the clearRanges portion of the script doesn't run on mobile even though the hideRows/Columns portion of the script does. Any ideas on why this might be? The function I'm using can be seen below:

function onOpen() {
//Create custom menu options
SpreadsheetApp.getUi().createMenu('Invoicing')
    .addItem("Clear Data", "clearRange")
    .addItem("Submit", "sendEmailWithPdfAttach")
    .addToUi()

//Clear ranges
var source = SpreadsheetApp.getActiveSpreadsheet();
source.getRange('A23:A40').clearContent();
source.getRange('H6:I6').clearContent();
source.getRange('H8:I8').clearContent();
source.getRange('F13:F13').setValue('FALSE');
source.getRange('F15:F15').setValue('TRUE');
source.getRange('D19:I19').clearContent();
source.getRange('D23:G23').clearContent();
source.getRange('D31:G31').clearContent();
source.getRange('A42:I44').clearContent();
source.getRange('B24:G25').clearContent();
source.getRange('B28:G29').clearContent();
source.getRange('B32:G33').clearContent();
source.getRange('B35:G40').clearContent();
source.getRange('H24:H29').clearContent();
source.getRange('H32:H33').clearContent();
source.getRange('H35:H39').clearContent();

//Hide rows/columns
var sheets = source.getSheets();
sheets.forEach(function (s, i) {
    if (i == sheetNum) {
        s.hideRows(45, 400);
        s.hideColumns(10, 17);
    } else {
        s.hideSheet();
    }
});    
}

自定义菜单选项供桌面使用,可以忽略.我还要说这是我第一次真正使用Apps Script,并且大部分代码是从其他地方获取并进行修改的.如果你们对我能做什么有什么头绪,我无所适从.谢谢

The custom menu options are for desktop use and can be ignored. I will also say this is my first time really using Apps Script, and most of this code was taken from elsewhere and modified. If you guys have any clue as to what I can do, I'm all ears. Thanks

推荐答案

SpreadsheetApp.getUi()在Google Sheets移动应用上不起作用.另一种方法是为Google表格创建Android加载项.不幸的是,目前不支持Google表格的其他移动平台加载项.

SpreadsheetApp.getUi() doesn't work on Google Sheets mobile apps. The alternative is to create Android add-ons for Google Sheets. Unfortunately at this time there isn't support for other mobile platform add-ons for Google Sheets.

  • Executing Google Apps Script Functions from Mobile App
  • google speadsheet api onOpen does not work on mobile ios

这篇关于使Google Apps脚本在移动设备上运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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