Apply multiple font colors to the text in a single Google Sheets cell

前端 未结 3 1299
情歌与酒
情歌与酒 2020-12-01 16:47

I am trying to format a cell to have multiple font colors using a function in Google Apps Script. I am unable to find any documentation on it. Also, using getFontColor

3条回答
  •  孤街浪徒
    2020-12-01 17:10

    requests = [
       
     object = {
            
        "updateCells": {
           "range": {
                "sheetId": sheetId,
            
                 "startRowIndex":startRowIndex,
                 "endRowIndex": endRowIndex,
            
                 "startColumnIndex": startColumnIndex,
                        
                 "endColumnIndex": endColumnIndex
            
                }
          "rows": [{
              "values": [{
                  "textFormatRuns": [
             
                      {"format": {
            
                        "foregroundColor": {
             
                           "red": 0.0,
            
                           "green": 255.0,
            
                           "blue": 31.0
            
                        },
            
                     },"startIndex": 0
             
                 },
            
               ]
            
             }
            
            ]
            
          }]
        "fields": "textFormatRuns(format)"
            
        }
           
     }
    ]
     
        try:
            
           result = service.spreadsheets().batchUpdate(spreadsheetId=internamiento_id, 
           body={'requests': requests}).execute()
            
           print('{0} celdas actualizadas'.format(result.get('totalUpdatedCells')))
        
        except Exception as e:
            print(e)
            json_salida["error"] = "Ocurrio un error "
            
        return json_salida, 400
    

提交回复
热议问题