I have a script that I use and update frequently for +3 spreadsheets, and I find it annoying to update each scripts separately every time. Would there be any ways to share (import/require) code from one place for each of those scripts?
I cannot have all these spreadsheets in the same file since they concern different clients.
My code contains functions as such:
function onOpen() {
var ui = SpreadsheetApp.getUi();
ui.createMenu('Custom Export')
.addItem('iOS', 'exportForIos')
.addItem('Android', 'exportForAndroid')
.addItem('JSON-iOS', 'exportJSONForIos')
.addItem('JSON-Android', 'exportJSONForAndroid')
.addToUi();
}
Google Apps Script actually allows to use a Script as a library and share code between various scripts.
```
function onOpen() {
Trad.onOpen();
}
function exportForIos() {
Trad.exportForIos();
}
function exportForAndroid() {
Trad.exportForAndroid();
}
function exportJSONForIos() {
Trad.exportJSONForIos();
}
function exportJSONForAndroid() {
Trad.exportJSONForAndroid();
}
function exportForAndroidToDrive() {
Trad.exportForAndroidToDrive();
}
function prefixSelectedCellsWith(chars) {
Trad.prefixSelectedCellsWith(chars);
}
```
Host it yourself (externally) and refer to it, would that work?
example:
<script src=" http://www.yourdomain.com/yourscripts/thescript.js"></script>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.