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

2024年5月13日月曜日

Google Slidesの表に値を入れたい Insert values into the specific table


Googleスライドの表に値を入れたくて試したコードです。
I tried to input values into a table in Google Slides via Apps Script.


Google Slidesで現在選択している表に値を入れたい - Insert values into the active table と似ていますが、表をコード内で指定するところが今回やりたいことです。
It's similar to an article I wrote before, but this time I want to specify the table within the code.



今回使うスライドの例
An example of the slide used for this demonstration.



Code.gs
function insertValuesIntoTable() {
var presentation = SlidesApp.getActivePresentation();
var slide = presentation.getSelection().getCurrentPage();
var tables = slide.getTables();
var table = tables[0];
var values = [
['Value 1', 'Value 2', 'Value 3'],
['Value 4', 'Value 5', 'Value 6'],
['Value 7', 'Value 8', 'Value 9']
];
for (var row = 0; row < values.length; row++) {
for (var col = 0; col < values[row].length; col++) {
if (row < table.getNumRows() && col < table.getNumColumns()) {
table.getCell(row, col).getText().setText(values[row][col]);
}
}
}
}


insertValuesIntoTable() を実行すると、0番目の表の中に、Code.gs内で指定した値(Value 1〜9)が入力されます。
Running insertValuesIntoTable() will fill the table index 0 with the values specified in the Code.gs (Value 1 through 9).


Reference

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

Latest post

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

IssueTracker > Apps Script issues https://issuetracker.google.com/savedsearches/566234 Google Apps Scriptの障害時は IssueTracker に課題が上がっていることが...