gspread – Add Formula to Google Spreadsheet Cells

gspread documentation does not have any examples of adding formulas to the cells. If you try to use them with append_row or update_cell methods it records them as a string and not as a Formula.

You should instead use the update_cell method

Updating a Single Cell, considering you know the exact Row and Column Number

worksheet2.update_acell('A45','=SUM(D45:F45)')

Updating a Single Cell, considering you the exact Row and Column Number are not known

cell = worksheet2.find("David Letterman")
row_number = cell.row
workbook2_row='A'+str(row_number)

worksheet2.update_acell(workbook2_row,'=INDIRECT(CONCATENATE("D",ROW()))-INDIRECT(CONCATENATE("E",ROW()))')

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s