TASK_TEMPLATE is a dynamic template rendering function that replaces placeholders in text with actual content from cells, URLs, documents, or other sources. It creates flexible documents and outputs by processing template strings and rendering the results to cells, Google Docs, or text files.
=TASK_TEMPLATE(header, template, [output_doc_name], [output_textfile_name], [celladdress])
Parameter | Data Type | Required | Description |
---|---|---|---|
header | string | No | Column header for the task template (used for UI display) |
template | string | Yes | The text template containing placeholders like {A1}, {Header}, {URL} |
output_doc_name | string | No | Optional name for a Google Doc to create with the template result |
output_textfile_name | string | No | Optional name for a text file to create with the template result |
celladdress | string | No | Optional cell address to place the result (defaults to cell right of function) |
TASK_TEMPLATE supports various placeholder types within curly braces {}
:
{A1}
, {B10}
- Content from specific cells{A}
, {B}
- Content from column in current row{Customer Name}
- Content from the column with this header{https://www.example.com}
- Content from web pages{https://www.example.com|markdown}
- Content in specified format (markdown/html/text){https://docs.google.com/document/d/...}
- Content from Google Docs{A1:A5,B1:B5}
- Key-value pairs from range pairsTASK_TEMPLATE offers flexible output cell targeting options:
"D5"
"current"
to output directly to the cell containing the function"E"
to target that column in the current rowWhen creating files with TASK_TEMPLATE:
=TASK_TEMPLATE("Customer Email", "Dear {A2},
Thank you for your purchase of {B2}. Your order #{C2} will be processed shortly.
Regards,
Customer Support")
=TASK_TEMPLATE("Report", "# Project Status Report
## Overview
{A5}
## Details
{B5:B10}
## Next Steps
{C5}", "Weekly Status Report")
=TASK_TEMPLATE("Data Export", "EXPORT DATE: {TODAY()}
CUSTOMER: {A1}
ORDER ID: {B1}
{C1:F10}", "", "order_export.txt", "G1")
=TASK_TEMPLATE("Invoice", "INVOICE
Customer: {Customer Name}
Product: {Product}
Amount: ${Amount}", "", "", "E5")
=TASK_TEMPLATE("Product Info", "# {A1} Information
{https://api.example.com/products/{B1}|markdown}
Price: ${C1}")
=TASK_TEMPLATE("Documentation", "# {A1} Documentation
## Overview
{B1}
## Details
{C1:C10}", "Project Docs", "project_text.md")
characters{Customer Name}
) instead of cell references for more maintainable templates"current"
celladdress option when you want to replace the formula with its resultCause: The function parameters weren't correctly formatted in the cell
Solution: Check that your formula syntax is correct, especially quotes and commas between parameters
Cause: A placeholder in your template couldn't be processed
Solution: Verify all cell references, URLs, and document IDs in your template are valid and accessible
Cause: Some placeholders might have invalid syntax or reference non-existent content
Solution: Check each placeholder follows the {value} format and references exist
Cause: The specified celladdress parameter has invalid formatting
Solution: Use a valid cell address format like "A1" or "B10" (always in quotes)
Cause: URL is invalid or unreachable from Google's servers
Solution: Verify the URL works, or try using the URL_READER function first to test access
Cause: The template needs to be executed via the Run button
Solution: After entering the formula, select the cell and click "Run" in the Sheet Workflows sidebar
Cause: Insufficient permissions to create Google Docs or text files
Solution: Ensure you have proper permissions in your Google Drive account
Use the
character sequence in your template string to create line breaks.
Not directly in the template, but you can reference Google Docs that contain images.
There's no hard limit, but very complex templates with many placeholders may take longer to process.
Yes, it uses the evaluated results of formulas, not the formula text itself.
The function creates content but doesn't send emails directly. You can copy the output or create a Doc to use in your email client.
Use the standard Sheet!Cell notation: {Sheet2!A1}
or reference the sheet name in a header.
Yes, markdown formatting in your template (headings, lists, etc.) will be converted to Google Docs formatting.
Yes, particularly when fetching URL content or creating Google Docs.
Yes, but very large results (>50K characters) will be automatically saved to a text file with a link in the output cell.
Google Docs has its own size limits (about 1.02 million characters). If your template exceeds this, consider splitting it into multiple templates.
The result will appear in the cell directly to the right of the cell containing the TASK_TEMPLATE formula.
No, each execution creates a new document. To update existing content, you would need to replace the existing file or doc.
1 week ago