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ドライブ内の音声ファイルをiframe内で再生したい

iframe の src にGoogleドライブ内の音声ファイルを埋め込む例です (今回試した音声ファイルはmp3) Code.gs function doGet () { return HtmlService . createTemplateFromFile ( ...