【问题标题】:How do I convert this google script to work offline?如何将此谷歌脚本转换为离线工作?
【发布时间】:2016-07-05 18:56:31
【问题描述】:

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

我知道谷歌驱动器是离线启用的,理论上 GAS 中的独立脚本应该可以解决问题,但我不确定如何将这些部分组合在一起。到目前为止,我有以下代码可以完美地在线运行(卡在离线“运行”中)并且我已经安装了 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-chrome google-apps-script google-sheets offline chromebook


    【解决方案1】:

    正如其他回复中所述,答案似乎是“否”。但是,在研究过程中,我确实找到了 Apps Script (clasp) 的命令行界面来离线管理和编辑您的项目。我将在此处发布,希望对 Apps Script 开发人员有所帮助。

    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 找到更多关于表扣的信息。但是,您还需要使用 these instructions 在 Chromebook 上激活 Linux(测试版)。

    【讨论】:

      【解决方案2】:

      简答

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

      说明

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

      Google Apps 脚本是一种基于 JavaScript 的脚本语言,它 让您可以使用 Google Apps(例如 Docs、Sheets、 和表格。无需安装 - 我们为您提供代码编辑器 直接在您的浏览器中,您的脚本在 Google 的服务器上运行。

      【讨论】:

      • 谢谢 Ruben,如果我用脚本创建了一个 webapp,还会这样吗?
      • @Tiana,是的,情况相同。
      猜你喜欢
      • 2018-08-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-19
      • 2012-09-18
      • 1970-01-01
      相关资源
      最近更新 更多