Skip to content

Instantly share code, notes, and snippets.

View Max-Makhrov's full-sized avatar
🇺🇦

Max Makhrov Max-Makhrov

🇺🇦
View GitHub Profile
@tanaikech
tanaikech / submit.md
Last active December 18, 2023 09:36
Managing Footnotes on Google Documents using Google Apps Script

Managing Footnotes on Google Documents using Google Apps Script

Description

Google Documents can be managed by the Document service of Google Apps Script. Ref One day, you might have a situation in which you are required to manage the footnotes on Google Documents using Google Apps Script. There are several official documents related to the footnotes for Google Apps Script. Ref and Ref However, unfortunately, I'm worried that it might be difficult a little to understand the management of the footnotes from these documents. Actually, I saw some questions related to the footnotes on Google Documents at Stackoverflow. In this report, I would like to introduce a method for managing the footnotes on Google Documents using Google

@tanaikech
tanaikech / submit.md
Created November 13, 2023 00:09
Technique for Processing Google Spreadsheet Including Merged Cells using Google Apps Script

Technique for Processing Google Spreadsheet Including Merged Cells using Google Apps Script

Description

At Google Spreadsheet, the cells can be merged as one cell. But, when the Spreadsheet including the merged cells is used with Google Apps Script, the script becomes a bit complicated. Also, I sometimes find some questions like this situation on Stackoverflow. In this report, I would like to introduce a technique for easily using the Spreadsheet including the merged cells with Google Apps Script.

Principle

Before it introduces the sample scripts, I would like to introduce the principle for using the Spreadsheet for the merged cells. You can understand the principle of this method from the following sample input and output images.

@tanaikech
tanaikech / sbmit.md
Created November 8, 2023 06:36
Uploading Files without Authorizing Scopes by Shared Users with Dialog on Google Spreadsheet using Google Apps Script

Uploading Files without Authorizing Scopes by Shared Users with Dialog on Google Spreadsheet using Google Apps Script

Abstract

One day, you might have a situation where you are required to make the shared users upload a file and text using a dialog or sidebar on Google Spreadsheet to your Google Drive and Spreadsheet without authorization by the users. This report introduces a solution for achieving this situation.

Introduction

Google Spreadsheet can run Javascript on a dialog and a sidebar. Ref These can be used as a strong tool for working on Spreadsheet. There might be a situation where you want to make the shared users input a value and upload a file without authorization of the scopes. In this report, I would like to introduce 2 patterns to achieve this goal.

@tanaikech
tanaikech / submit.md
Created October 26, 2023 06:47
Retrieve Comments with Emoji Reactions from Google Documents, Google Slides, and Google Spreadsheets using Google Apps Script

Retrieve Comments with Emoji Reactions from Google Documents, Google Slides, and Google Spreadsheets using Google Apps Script

Abstract

This report introduces the method for retrieving the Emoji reactions from the comments in Google Docs files (Google Documents, Google Slides, and Google Spreadsheets) using Google Apps Script.

Introduction

@tanaikech
tanaikech / submit.md
Last active February 18, 2024 16:34
Executing Google Apps Script with Service Account

Executing Google Apps Script with Service Account

Abstract

One day, you might have a situation where it is required to run Google Apps Script using the service account. Unfortunately, in the current stage, Google Apps Script cannot be directly run with the service account because of the current specification. So, this report introduces a workaround for executing Google Apps Script using the service account.

Introduction

@pallocchi
pallocchi / saveNewAttachmentsToDrive.js
Last active September 22, 2023 18:50
Automatically Save Email Attachments to Google Drive Using Google Apps Script
function saveNewAttachmentsToDrive() {
var folderId = "PUT_YOUR_FOLDER_ID_HERE"; // Replace with the ID of the destination folder in Google Drive
var searchQuery = "to:your-email@example.com has:attachment"; // Replace with the search query to find emails with attachments
var lastExecutionTime = getLastExecutionDate();
var threads = GmailApp.search(searchQuery + " after:" + lastExecutionTime);
var driveFolder = DriveApp.getFolderById(folderId);
for (var i = 0; i < threads.length; i++) {
var messages = threads[i].getMessages();
for (var j = 0; j < messages.length; j++) {
var message = messages[j];
@tanaikech
tanaikech / submit.md
Created July 24, 2023 00:13
Overwrapped Cells on Google Spreadsheet using Google Apps Script

Overwrapped Cells on Google Spreadsheet using Google Apps Script

This is a sample script for checking the overwrapped cells of multiple ranges on Google Spreadsheet using Google Apps Script.

When applications are developed, there might be a case that it is required to confirm whether 2 ranges on Google Spreadsheet are overwrapped. In this post, I would like to introduce a sample script for achieving this.

Method: getOverwrappedCells

@tanaikech
tanaikech / submit.md
Last active June 27, 2023 10:44
Comparing File Contents of Files on Google Drive using Google Apps Script

Comparing File Contents of Files on Google Drive using Google Apps Script

This is a sample script for comparing the file contents of files on Google Drive using Google Apps Script.

Sample script

Before you use this script, please enable Drive API at Advanced Google services. And also, please set the file IDs you want to check whether the file contents of the files are the same.

function checkFiles_(f, checks = ["md5Checksum", "sha1Checksum", "sha256Checksum"]) {
@tanaikech
tanaikech / submit.md
Last active June 21, 2023 11:39
Workaround: Exporting Google Documents as HTML with Image Hyperlinks

Workaround: Exporting Google Documents as HTML with Image Hyperlinks

This is a sample script for exporting Google Documents as HTML with the image hyperlinks using Google Apps Script.

Recently, it seems that the specification for exporting Google Documents as HTML data has been changed. When a Google Document are exported as HTML data before, the images in the Google Document were the image hyperlinks, which are publicly shared. But, in the current stage, when a Google Document is exported as HTML data, the images in the Google Document are the data URL (base64 data) of the images. I guess that this might be related to enhancing the security. When the Google Document is exported as a ZIP file, the HTML and images are separated. But, in this case, the images are required to be included in a specific folder like "/images". I'm worried that this might bring another issue.

From the above situation, in the current stage, when a Google Document including images is exported as HTML data, the size of the HTML da

@tanaikech
tanaikech / submit.md
Last active June 5, 2023 11:50
Report: Specification of Properties Service for Google Apps Script

Report: Specification of Properties Service for Google Apps Script

Abstract

In this report, the detailed specification of PropertiesService has been investigated. It is considered that knowing this specification will be useful for developing applications with Google Apps Script. As a result, it was found that the maximum key and value sizes are 524,287 bytes with a 1-byte key and 8,066 bytes, respectively. And also, it was found that the maximum size of PropertiesService is required to be considered with both the key and value sizes.

Introduction