IssueTracker: Bug for scopes of Slides
I have reported because I found a bug for scopes of Slides. The detail is the following URL.
I have reported because I found a bug for scopes of Slides. The detail is the following URL.
This sample script is converted this sample script (javascript) to Google Apps Script. The point for converting is signature as shown in the following sample script.
"/api/" + apiPath + nonce + rawBody is encrypted using HMAC SHA-384, the data of byte array is converted to HEX.
Utilities.computeHmacSignature() is the bytes array of the signed hexadecimal.crypto.createHmac('sha384', apiSecret).update(signature).digest('hex') is the string of the unsigned hexadecimal.In order to achieve above, I made the method of bytesToHex().
This sample script is for splitting string by N characters for batch-file. In this sample, after it retrieves N characters from the first character of STR, the N characters are removed from STR. This is repeated until the end of STR.
@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
SET "STR=ABCDEFGHIJKLMNOPQRSTUVWXYZ"
REM Split STR by N characters
SET "N=2"
:LOOP
SET "RES=%RES%!STR:~0,%N%! "
SET "STR=!STR:~%N%!"
IF DEFINED STR GOTO LOOP
ECHO "%RES:~0,-1%"
N=2"AB CD EF GH IJ KL MN OP QR ST UV WX YZ"
N=5"ABCDE FGHIJ KLMNO PQRST UVWXY Z"
In this report, I would like to introduce a workaround for automatically recalculating custom functions on Spreadsheet.
The sample situation is below. This is a sample situation for this document.
function myFunction(e) {
var r = 0;
var sheets = SpreadsheetApp.getActiveSpreadsheet().getSheets();
for (var i in sheets) {
r += sheets[i].getRange(e).getValue();
}
return r;
}
When =myFunction("A1") is put in a cell, the custom function sums each “A1” of “sheet1”, “sheet2” and “sheet3”. But in this case, when “A1” of one of 3 sheets is changed, the custom function is not recalculated.
Recently, I have reported RearrangeScripts for rearranging scripts in a GAS project. At that time, I got messages and mails from many developers. They said that you should publish this as an add-on. So, this was released. Now you can search “RearrangeScripts” as an add-on for Spreadsheet. If this is helpful for you, I’m happy.
This is a sample script for decoding Gmail body with Japanese language using Python.
msg = service.users().messages().get(userId='me', id=id).execute()
parts = msg['payload']['parts']
for e in parts:
msg = base64.urlsafe_b64decode(e['body']['data']).decode('utf-8').encode('cp932', "ignore").decode('cp932')
print(msg)
This is a document for explaining the difference between given values and retrieved values for shapes on Google Slides. When a shape is created to a slide using Slides API, most users give the size of height and width as pt. When the size is retrieved from the created shape as pt, the size is often difference from the given size.
For example, when a square shape is created by giving the height and width of 100 pt, the size which is retrieved from the created square becomes 99.99212598425197 pt for the height and width.
This is a sample script for retrieving clientId using Google Apps Script.
var accessToken = ScriptApp.getOAuthToken();
var url = "https://www.googleapis.com/oauth2/v3/tokeninfo?access_token=" + accessToken;
var params = {
method: "post",
headers: {"Authorization": "Bearer " + accessToken}
};
var res = UrlFetchApp.fetch(url, params).getContentText();
var clientId = JSON.parse(res).azp;
Logger.log(clientId)
This is a sample script for downloading a file using a button of dialog box on Google Docs (Spreadsheet, Document and Slides).
Please use this sample script at script editor on Google Docs (Spreadsheet, Document and Slides). And please set file ID in the script.
The flow of this sample script is as follows.
dialog().
download(obj) of Javascript.function dialog() {
var html = HtmlService.createHtmlOutputFromFile('download');
SpreadsheetApp.getUi().showModalDialog(html, 'Sample dialog'); // If you use other Google Docs, please modify here.
}
function getDownloadUrl() {
var id = "### file id ###";
var file = DriveApp.getFileById(id);
return {
url: file.getDownloadUrl().replace("?e=download&gd=true",""),
filename: file.getName()
};
}
<input type="button" value="download" onclick="getUrl()" />
<script>
function getUrl() {
google.script.run.withSuccessHandler(download).getDownloadUrl();
}
function download(obj) {
var d = document.createElement('a');
d.href = obj.url;
d.download = obj.filename;
d.click();
}
</script>