TASK_FORMAT is a custom function that generates formatting instructions for spreadsheet ranges using natural language prompts and AI models. It defines formatting operations to be applied to cells, allowing users to easily create professional-looking sheets without manual formatting.
=TASK_FORMAT(header, range, prompt, [model], [freeze_range])
Parameter | Data Type | Required | Description |
---|---|---|---|
header | string | Yes | Column header for the task template |
range | string | Yes | The range to apply formatting to (e.g., "A1:B10") |
prompt | string | Yes | Natural language instructions describing the formatting to apply |
model | string | No | The language model to use (format: "provider/model_name"). Default model is used if not specified |
freeze_range | string | No | Range of cells which should NOT be modified (e.g., "A1:A3") |
You can describe formatting in plain English. For example:
The freeze_range
parameter not only prevents those cells from being modified, but also sets the frozen panes in your sheet. For example, setting freeze_range
to "A1:C2" will freeze the first 2 rows and first 3 columns.
While you can use any supported language model, models with stronger reasoning abilities like "Gemini/gemini-1.5-pro" or "Anthropic/claude-3-opus" tend to produce better formatting results, especially for complex formatting instructions.
=TASK_FORMAT("Format Headers", "A1:F1", "Make these headers bold, centered, with a dark blue background and white text")
=TASK_FORMAT("Sales Highlighting", "B2:B20", "Highlight cells in green if greater than 5000, yellow if between 3000-5000, and red if less than 3000")
=TASK_FORMAT("Format Table", "A1:E10", "Create a professional-looking table with alternating row colors, bold headers, gridlines, and currency format for columns C and D")
=TASK_FORMAT("Dashboard Format", "A1:G15", "Format as a dashboard with bold headers, right-aligned numbers, and date format in column A", "Gemini/gemini-1.5-pro", "A1:G1")
freeze_range
parameter to both protect important data and set frozen panesCause: The specified range doesn't exist or is malformed.
Solution: Verify that the range exists in your sheet and uses proper A1 notation (e.g., "A1:B10").
Cause: The formula has syntax errors or invalid parameters.
Solution: Check that all parameters are correctly entered and comma-separated.
Cause: No default model is set and no model parameter was provided.
Solution: Either specify a model in the formula (e.g., "Gemini/gemini-1.5-pro") or configure a default model in Settings.
Cause: Prompt instructions were ambiguous or too complex.
Solution: Make instructions more specific and break complex formatting into multiple TASK_FORMAT calls.
Cause: Range might include empty cells or cells with unexpected content.
Solution: Check if your range contains the expected data and adjust if needed.
Cause: The language model couldn't generate proper formatting instructions.
Solution: Simplify your prompt, try a different model, or break down your request into simpler instructions.
TASK_FORMAT allows you to describe formatting in natural language, handle complex conditional formatting, and apply multiple formatting attributes simultaneously. It's like having a design assistant for your spreadsheet.
Yes, you can use prompts like "Apply the same formatting as in range A1:B5" to instruct the model to replicate existing formatting patterns.
The more specific you are, the better the results. Instead of "make it look nice," try "make headers bold, centered, with light blue background, and apply alternating row colors to data rows."
Yes, it will apply the new formatting to the specified range. If you want to preserve certain elements, specify that in your prompt or use the freeze_range parameter.
Yes, you can describe formula-based conditions in your prompt, like "highlight cells where the value is greater than the average of the column."
Currently, TASK_FORMAT works on one sheet at a time. For multiple sheets, you'll need to create separate TASK_FORMAT calls for each sheet.
While there's no hard limit in the function, Google Sheets itself has limits on conditional formatting rules. For very complex formatting needs, consider breaking it into multiple TASK_FORMAT calls.
TASK_FORMAT primarily handles visual formatting. For data validation rules, you'll need to use Sheet's built-in data validation features.
Yes, once applied, the formatting becomes part of the sheet and will be visible to anyone with access to the sheet.
You can use Google Sheets' Clear formatting option or create another TASK_FORMAT with instructions to reset formatting to default.
1 week ago