Skip to content Skip to sidebar Skip to footer

Updating Cell Format Using Smartsheet Api (python Sdk)

I'm trying to write both values and display formatting to a smartsheet. I access the sheet with: import os import re import logging import smartsheet file_pssw = open('path2accesst

Solution 1:

This is adapted from the Update Rows example in the docs to include the format attribute. It is important to note that to update a cell's formatting you have to include the value attribute as well. You will want to use the current value of the cell if you don't want to change that.

Note that when building the cell object format is preceded by an underscore. I should also point out that in this process I am constructing a NEW cell object and a NEW row object for the request rather than modifying any existing objects.

# Build new cell value

new_cell = ss_client.models.Cell()
new_cell.column_id = <COLUMN_ID>
new_cell.value = 2
new_cell._format = ",,,,,,,,27,,,,,,,"# Build the row to update

new_row = ss_client.models.Row()
new_row.id = <ROW_ID>
new_row.cells.append(new_cell)

# Update rows

updated_row = ss_client.Sheets.update_rows(
<SHEET_ID>, # sheet_id
[new_row])

Post a Comment for "Updating Cell Format Using Smartsheet Api (python Sdk)"