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 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 に課題が上がっていることが...