robin900 / gspread-formatting

Complete cell formatting support for Google spreadsheets via gspread package.

Repository from Github https://github.comrobin900/gspread-formattingRepository from Github https://github.comrobin900/gspread-formatting

Formatting single cell

jawadcode opened this issue · comments

Is there any way to format a single cell using integer row and column notation instead of strings, for example:
2, 3 instead of 'b3'

First, you can only format "ranges", so to format a single cell, use a range that duplicates the single cell's label: for cell A1, use range "A1:A1".

Next, you can always use the utility function rowcol_to_a1 from gspread.util to convert your row and column integers to an A1-style label:

from gspread.utils import rowcol_to_a1
from gspread_formatting import *

cell_a1 = rowcol_to_a1(my_row, my_col)
format_cell_range(my_sheet, '%s:%s' % (cell_a1, cell_a1), my_format)

Closing this issue.