Apps Script公式リファレンス: Apps Script Reference |障害・課題追跡: IssueTracker |Google Workspace: Status Dashboard - Summary


Google Slidesで現在選択している表に値を入れたい7 - Insert values into the active table7

This article is a variation of the following link.

This time, create a dialog for copying values from a spreadsheet and pasting them into a table in a slide.


Prepare the values in the spreadsheet in 4 rows and 3 columns. (In the example, A2:C5)

Copy the entered 4x3 values.

下記Apps ScriptのCode.gsで modalessTemplate() を実行してダイアログを表示します。
Display the dialog by executing the modalessTemplate() function in the Apps Script below.

Paste the copied values into the text area.

After clicking the submit button, the values are entered into the table in the slide.

Apps Script
function modalessTemplate() {
const htmlOutput = HtmlService
SlidesApp.getUi().showModelessDialog(htmlOutput, "MyGUI");

function include(filename) {
return HtmlService.createHtmlOutputFromFile(filename).getContent();

function setValuesForTables(records) {
const arrays = createArrays(records);
const table = getSelectedTable();
setValuesInTable(table, arrays, 0, 1);

function getSelectedTable() {
const presentation = SlidesApp.getActivePresentation();
const selection = presentation.getSelection();
const pageElement = selection.getPageElementRange().getPageElements()[0];
const table = pageElement.asTable();
return table;

function createArrays(records) {
let arrays = [];
for(let i = 0; i < records.length; i++) {
const units = records[i].split("\t");
const values = [units[0], units[1] + "\n" + units[2]];
return arrays;

function setValuesInTable(table, values, startRow = 0, startCol = 0) {
for (let row = 0; row < values.length; row++) {
for (let col = 0; col < values[row].length; col++) {
if (row + startRow < table.getNumRows() && col + startCol < table.getNumColumns()) {
table.getCell(row + startRow, col + startCol).getText().setText(values[row][col]);

<!DOCTYPE html>
<?!= include("css"); ?>
<textarea id="input"></textarea>
<button id="submit">submit</button>
<?!= include("javascript"); ?>

#input {
font-size: 12px;
width: 95vw;
height: 80vh;

function elem(id) {
return document.getElementById(id);

elem('input').addEventListener('keyup', inputKeyup);
elem('submit').addEventListener('click', submitClicked);

function inputKeyup() {
elem("input").value = elem("input").value.replace(/"/g, "");

function submitClicked() {
const records = elem("input").value.split("\n");;


When we copy a cell containing a newline from a spreadsheet and paste it into a text editor, it gets enclosed in double quotation marks (").

The following code removes double quotes when pasting values.

elem("input").value = elem("input").value.replace(/"/g, "");

スプレッドシートのセルを選択してコピーすると、セルは 以下のようにタブ文字「\t」 で区切られています。
When we select and copy cells from a spreadsheet, the cells are separated by the tab character "\t", as shown below.
get\tTo obtain or receive something.\t何かを手に入れる、または受け取ること。

The following code creates an array by splitting a string at the tab characters.

const units = records[i].split("\t");

After that, the elements at index 1 and index 2 are joined with a newline character "\n".

const values = [units[0], units[1] + "\n" + units[2]];


Google Slidesで現在選択している表に値を入れたい6 - Insert values into the active table6

Latest post

Google Apps Scriptの障害時はIssueTrackerを見てみる - Incidents for Apps Script are reported on Issue Tracker

IssueTracker > Apps Script issues Google Apps Scriptの障害時は IssueTracker に課題が上がっていることが...