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

Support getting and setting `TextFormatRuns` (was: Does gspread-formatting support changing text colors of a substring in a cell?)

Amerimac-Github opened this issue · 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

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 thanks, will do.