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でクイズを作りたい

Googleフォームには回答を判定するクイズモードがあります 今回はそのクイズモードで回答の判定とフィードバックについて書いていきます 「クイズモード」の表記: 日本語の表記は「テストにする」ですが 英語の表記は「Make this a quiz」となっています この記事ではでは...