如何将该Google脚本转换为脱机工作? [英] How do I convert this google script to work offline?

查看:101
本文介绍了如何将该Google脚本转换为脱机工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am trying to automate data entry while roaming offline using my Chromebook.

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

I know that google drive is enabled offline and a standalone script in GAS should in theory do the trick but im not sure how to put the pieces together. So far I have the below code which works perfectly online (gets stuck in "running" offline) and I've got the GAS app installed. Any guidance would be greatly appreciated!

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脚本无法脱机运行,因为它们在服务器端运行.

Short answer

Google Apps Script can't be ran offline because they run on the server-side.

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

Google Apps脚本是一种基于JavaScript的脚本语言, 可让您使用Google Apps做一些新奇而有趣的事情,例如文档,表格, 和表格.无需安装-我们为您提供代码编辑器 直接在您的浏览器中,您的脚本就可以在Google的服务器上运行.

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.

这篇关于如何将该Google脚本转换为脱机工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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