简体   繁体   English

电子表格宏的版本控制

[英]Version control of spreadsheet macros

So a while ago my fiancée asked me to help her create a spreadsheet to manage her new small business. 不久前,我的未婚妻让我帮她创建一个电子表格来管理她的新小企业。 Come to find out she was actually looking for a fully-fledged CRM. 来发现她实际上正在寻找一个完全成熟的CRM。 Being the good future husband I am, I decided I could tackled this with some GoogleSheets macros. 作为我未来的好丈夫,我决定用一些GoogleSheets宏来解决这个问题。 About two weeks in, I have basic inventory handling down, but the project has gotten way bigger than I had ever anticipated. 大约两周后,我有基本的库存处理,但项目已经比我预期的要大。 The in-browser Syder IDE and basic version management isn't really cutting it any more. 浏览器内的Syder IDE和基本版本管理并没有真正削减它。

My question now: I would like to begin managing this project in gitHub, but I can't find a graceful way to do so. 我现在的问题是:我想在gitHub中开始管理这个项目,但是我找不到一个优雅的方法。 I've found this blog post on stand-alone apps script files, but I can't seem to find my macro (.gs) files in my Google Drive. 我在独立的应用程序脚本文件上发现了这篇博文,但我似乎无法在我的Google云端硬盘中找到我的宏(.gs)文件。

My questions: Where are these files located? 我的问题:这些文件位于何处? Is there a way to use eg eclipse to develop my macros and store them back to the spreadsheet while also using git or other version control? 有没有办法使用例如eclipse来开发我的宏并将它们存储回电子表格,同时还使用git或其他版本控制?

Edit: Got some great feedback so far, but apparently Cloud Tools for Eclipse do not allow for Apps Script editing in the same way the Google Plugin for Eclipse did, see here . 编辑:到目前为止得到了一些很好的反馈,但显然Cloud Tools for Eclipse不允许像Eclipse插件的Eclipse插件那样编辑Apps脚本,请参见此处

Once you're done migrating your code to a stand-alone script as per Michelle's instructions you may want to check out this Chrome Extension: 根据Michelle的说明完成将代码迁移到独立脚本后,您可能需要查看此Chrome扩展程序:

Google Apps Script Github Assistant Google Apps脚本Github助手

It integrates with the Apps Script GUI to push and pull source to and from github. 它与Apps Script GUI集成,可以向github推送源和从github获取源。 Its a pretty handy tool. 它是一个非常方便的工具。

PS The Chrome extension also works with bound scripts, but I've found that Apps Script code is easier to reuse when they are stand-alone scripts. PS Chrome扩展程序也适用于绑定脚本,但我发现Apps脚本代码在独立脚本时更容易重用。

As Anton said, it is impossible to access a spreadsheet-bound script file outside of Google Sheets interface. 正如Anton所说,无法访问Google表格界面之外的电子表格绑定脚本文件。 You can copy-paste all of the code in a new stand-alone Google Script file. 您可以在新的独立Google Script文件中复制粘贴所有代码。 However, this will likely take some code changes, described below. 但是,这可能需要进行一些代码更改,如下所述。

The calls to SpreadsheetApp.getActiveSpreadsheet will need to be replaced by SpreadsheetApp.openById , with the Id of the spreadsheet hardcoded. SpreadsheetApp.getActiveSpreadsheet的调用需要由SpreadsheetApp.openById替换, SpreadsheetApp.openById的Id是硬编码的。 Other getActive* methods like getActiveSheet and getActiveRange can be invoked on that spreadsheet object, instead of SpreadsheetApp directly. 可以在该电子表格对象上调用getActiveSheetgetActiveRange等其他getActive *方法,而不是直接调用SpreadsheetApp。

Any simple triggers such as onOpen or onEdit will need to be replaced by installable triggers that are installed in the spreadsheet by the standalone script. 任何简单的触发器(如onOpen或onEdit)都需要由独立脚本安装在电子表格中的可安装触发器替换。 So, the script should have a function installing, say, onOpen, that will need to be executed manually once. 因此,脚本应该有一个安装的函数,比如onOpen,需要手动执行一次。 See sample code for installing a trigger . 请参阅安装触发器的示例代码

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM