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

2024年5月22日水曜日

Google SlidesにApps Scriptで表を配置したい


Google SlidesにApps Scriptで表を配置したくて試したコードです。
I tried writing Apps Script to place a table in Google Slides.


今回の例では、4行3列の表を配置します。
In this example, we will place a 4-row, 3-column table.


手動で配置する場合は、挿入 > 表 > 行列選択で配置します。
To place a table manually, go to Insert > Table > Select rows and columns.



Code.gs
function createTableInGoogleSlides() {
const presentation = SlidesApp.getActivePresentation();
const slide = presentation.getSelection().getCurrentPage();

const numRows = 4;
const numCols = 3;
const table = slide.insertTable(numRows, numCols);
table.setLeft(20).setTop(30);
}


createTableInGoogleSlides()を実行すると、左から20、上から30の位置に4行3列の表が配置されます。
After execute "createTableInGoogleSlides()", a table with 4 rows and 3 columns will be placed at a position 20 points from the left and 30 points from the top of the slide.


Reference

insertTable(numRows, numColumns)

insertTable(numRows, numColumns, left, top, width, height)

setLeft(left)

setTop(top)

Latest post

Google Formsのグリッドで「1 列につき 1 つの回答に制限」したい

今回はグリッドの質問で右下の︙メニューにある「1 列につき 1 つの回答に制限」を試してみます フォームの編集画面 フォームの回答画面 同じ列で2つ以上選択するとエラー表示が出るようになります それぞれの列で選択できるのはひとつだけ Apps Scriptで実装する場合に追加する...