gspread-formatting icon indicating copy to clipboard operation
gspread-formatting copied to clipboard

Does gspread-formatting support changing text colors of a substring in a cell?

Open Amerimac-Github opened this issue 1 year ago • 2 comments

I'm looking to build a utility that checks the spelling of one cell against another, and color codes individual words. Is this possible with gspread-formatting ? If so, please just mention the feature/method and I can figure it out from the docs (I just don't see it at first pass through the read the docs). The docs are good I just can't find this capability. Is it possible or do I need to handroll w the native sheets API?

image

Amerimac-Github avatar Apr 24 '24 13:04 Amerimac-Github

Sheets API support for "text format runs" is pretty new, and the textFormatRuns array property of CellData didn't exist when gspread-formatting was authored.

This is a good feature to request. I'll make this issue a feature request and work on it should begin fairly soon.

In the meantime, you need a workaround. I recommend exploring the API of Worksheet in the gspread package, and find a way to do a batch update with a RepeatCellRequest for each cell you want to have mixed formatting. Look in the Sheets API docs for RepeatCellRequest, CellData and TextFormatRun for guidance. Good luck!

robin900 avatar Apr 24 '24 14:04 robin900

@robin900 thanks, will do.

Amerimac-Github avatar Apr 24 '24 14:04 Amerimac-Github