val service = ...val spreadsheetId = ...val sheetId = 0val requests = listOf<Request>( // set Col A to AutoResize Request().setAutoResizeDimensions( AutoResizeDimensionsRequest().apply { dimensions = DimensionRange().apply { this.sheetId = sheetId dimension = "COLUMNS" startIndex = 0 // A endIndex = 1 } } ), // set Col B to 350 Request().setUpdateDimensionProperties( UpdateDimensionPropertiesRequest().apply { range = DimensionRange().apply { this.sheetId = sheetId dimension = "COLUMNS" startIndex = 1 // B endIndex = 2 } properties = DimensionProperties().apply { pixelSize = 300 } fields = "pixelSize" } ))val body = BatchUpdateSpreadsheetRequest().setRequests(requests)service.spreadsheets().batchUpdate(spreadsheetId, body).execute()
NOTE: service
is Sheets. Refer to Get Google Sheets service instance.
NOTE: Refer to Get Sheet Id.
References: