如何使文本对齐:在 google 应用程序脚本(日历)中居中?

How to make text-align: center in google app-script (Calendar)?

我在应用程序脚本中新建了一个,我只想使用 CardService.newTextParagraph()

粘贴和对齐文本
CardService.newTextParagraph()
        .setText(text)

我想用这样的东西

CardService.newTextParagraph()
        .setText(text)
        .setAlignment(DocumentApp.HorizontalAlignment.CENTER);

但它的功能和枚举仅在文档应用程序中可用。

默认情况下,插件文本左对齐。我只想将它对齐在中心。 有没有人有一些建议或建议,我该怎么做? 谢谢

对齐文本可以使用classClass网格。

文档https://developers.google.com/apps-script/reference/card-service/grid

用法 -

function buildCard() {
    const cardSection1GridItem = CardService.newGridItem()
        .setTitle('Title')
        .setSubtitle('Subtitle')
        .setTextAlignment(CardService.HorizontalAlignment.CENTER)
        .setLayout(CardService.GridItemLayout.TEXT_BELOW);

    const cardSectionGrid = CardService.newGrid()
        .setNumColumns(1)
        .setTitle('Grid')
        .addItem(cardSection1GridItem);

    const cardSection1 = CardService.newCardSection()
        .addWidget(cardSectionGrid);

    const card = CardService.newCardBuilder()
        .addSection(cardSection1)
        .build();
        
    return card;
}