如何将此 google 脚本转换为脱机工作?

How do I convert this google script to work offline?

我正在尝试使用 Chromebook 在离线漫游时自动输入数据。

我知道 google 驱动器是离线启用的,理论上 GAS 中的独立脚本应该可以解决问题,但我不确定如何将这些部分组合在一起。到目前为止,我有以下代码可以完美地在线运行(卡在 "running" 离线状态)并且我已经安装了 GAS 应用程序。任何指导将不胜感激!

function onOpen() {
var ui = SpreadsheetApp.getUi();
// Or DocumentApp or FormApp.
ui.createMenu('Invoice/Receipt System')
// creates a menu item "Submit Order"
.addItem('Record Invoice', 'menuItem1')
.addToUi();
}


function menuItem1() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var is = ss.getSpreadsheetByName("Template_Invoice");

  var lastID = is.getRange("j6");
  var nextID = is.getRange("j7");

  var lastIDValue = lastID.getValue();

var source = ss.getSpreadsheetByName("Key_Invoice"); 
// sets the 'Key_DailyInput' Sheet as source
var target = ss.geSpreadsheetByName("DataBase_Invoice");
// sets 'Key_DailyInput' sheet as the target for copying data to.
var sourceData = source.getSheetValues(5,1,source.getLastRow(),15);
// sets range to gather source 'Key_DailyInput' data by finding last row, and Line 5 to Column 15
target.getRange(target.getLastRow()+1, 1, sourceData.length,15).setValues(sourceData);
// finds last row of target 'Orders' and writes to +1 row past last row up to column 15 using setValues of sourceData

// Following simply clears DailyInput so new data can be entered
is.getRange('C5:c8').clearContent();
is.getRange('G7:G8').clearContent();
is.getRange('B12:h28').clearContent();
is.getRange('b31:b34').clearContent();


// increases value by +1 so next Sales Order ID is incremented by 1
var cell = is.getRange("j6");
var cellValue = cell.getValue();
cell.setValue(cellValue + 1);

nextID.setValue(lastIDValue + 1);
}

简答

Google Apps 脚本无法 运行 离线,因为它们 运行 在服务器端。

说明

来自https://developers.google.com/apps-script/overview

Google Apps Script is a scripting language based on JavaScript that lets you do new and cool things with Google Apps like Docs, Sheets, and Forms. There's nothing to install — we give you a code editor right in your browser, and your scripts run on Google's servers.

如其他回复所述,答案似乎是 'No'。但是,在研究过程中,我确实找到了 Apps 脚本的命令行界面 (clasp) 来离线管理和编辑您的项目。我将 post 放在这里,希望它对 Apps 脚本开发人员有所帮助。

CLASP Features
Develop Locally. clasp lets you write code on your own computer and upload it to Apps Script via command line when you're done. You can also download existing Apps Script projects and then edit them locally. Once the code is local, you can use your favorite development tools like git to work on Apps Script projects.
*  Manage Deployment Versions. 
*  Create, update, and view multiple deployments of your project.
*  Structure Code. clasp automatically converts your flat project on script.google.com into folders.

您可以在 https://developers.google.com/apps-script/guides/clasp. However, you'll also need to activate the Linux(beta) on your Chromebook utilizing these instructions.

找到更多关于 clasp 的信息