Google Apps Script Text rotation

后端 未结 2 1961
时光说笑
时光说笑 2021-01-14 02:44

I found in the UI of Google Spreadsheet the functionality Text Rotation but i found no equal function in google apps script.

So how can i rotate Text with Google app

相关标签:
2条回答
  • 2021-01-14 03:24

    I know this is an old ask but incase others are interested...This can be done now. Just add .setTextRotation() to any range selected and it will rotate the text to the desired degree. For example:

    SpreadsheetApp.getActiveSpreadsheet().getSheets()[0].getRange(1,1).setTextRotation(-45);
    

    Documentation: https://developers.google.com/apps-script/reference/spreadsheet/range-list#setTextRotation(Integer)

    0 讨论(0)
  • 2021-01-14 03:25

    You may follow the formula given in this thread. Here's a sample code:

    function myFunction() {
      var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
      var cell = sheet.getRange(1,1);
      cell.setValue('=ARRAYFORMULA(CONCATENATE((MID($B2, ROW(INDIRECT("YY1:YY"&LEN($B2))), 1)&CHAR(10))))');
    }
    

    In this example, we'll set the value of B2 in A1 in vertical format. Hope this helps.

    0 讨论(0)
提交回复
热议问题