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

2024年5月23日木曜日

Google Slidesの表でセルの幅を変えたい - Change the width of cells in a table in Slides.


この記事で実行するコードは、上記のリンク先でも利用したGoogle Slides APIを追加する必要があります。
The code executed in this article requires the Google Slides API, which was also used in the link above.


今回はGoogle Slidesで現在選択肢している表のセルの幅を指定するコードを試しました。
This time, I tried the code to specify the width of the currently selected table cells in Google Slides.


配置してある4行3列の表で、セルの幅を変更するコードです。
The code is to change the width of cells in an existing 4-row, 3-column table in Google Slides.



Code.gs
function createTableInGoogleSlides() {
const presentation = SlidesApp.getActivePresentation();
const selection = presentation.getSelection();
const pageElement = selection.getPageElementRange().getPageElements()[0];
const table = pageElement.asTable();
const objectId = table.getObjectId();

const resource = {
requests: [
{
updateTableColumnProperties: {
tableColumnProperties: {
columnWidth: {
magnitude: 100, unit: "pt"
}
},
columnIndices: [0,1],
objectId: objectId,
fields: "columnWidth"
}
},
{
updateTableColumnProperties: {
tableColumnProperties: {
columnWidth: {
magnitude: 300, unit: "pt"
}
},
columnIndices: [2],
objectId: objectId,
fields: "columnWidth"
}
},
{
updateTableRowProperties: {
tableRowProperties: {
minRowHeight: {
magnitude: 60, unit: "pt"
}
},
rowIndices: [1,2,3],
objectId: objectId,
fields: "minRowHeight"
}
}
]
};
Slides.Presentations.batchUpdate(resource, presentation.getId());
}



Tips

Google Slides APIは以下のように追加します。
You can add the Google Slides API as follows:


サービス > Google Slides API > 追加
Services > Google Slides API > Add


Reference

Setting width and height of tables with Google Slides Apps Script

Google Slides API > Request

Google Slides API > UpdateTableColumnPropertiesRequest

Google Slides API > UpdateTableRowPropertiesRequest

Google Slides API > Tables

Google Slidesの表でセルを結合したい - merge cells in a table on Google Slides

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