Organiza tus páginas con colecciones Guarda y categoriza el contenido según tus preferencias.
TextOutput
Un objeto TextOutput que se puede entregar desde una secuencia de comandos.
Por motivos de seguridad, las secuencias de comandos no pueden mostrar contenido de texto directamente a un navegador. En su lugar, el navegador se redirecciona a googleusercontent.com, que lo mostrará sin ninguna limpieza ni manipulación adicionales.
Puedes mostrar contenido de texto de la siguiente manera:
Establece el tipo mime para el contenido que se publicará.
Documentación detallada
append(addedContent)
Agrega contenido nuevo al contenido que se publicará.
Parámetros
Nombre
Tipo
Descripción
addedContent
String
el contenido que se agregará
Volver
TextOutput: Este TextOutput en sí, útil para encadenar
clear()
Borra el contenido actual.
Volver
TextOutput: Este TextOutput en sí, útil para encadenar
downloadAsFile(filename)
Indica a los navegadores que descarguen este contenido en lugar de mostrarlo.
Algunos navegadores ignorarán este parámetro de configuración. Si lo estableces en nulo, se restablecerá el comportamiento predeterminado de mostrar en lugar de descargar.
Parámetros
Nombre
Tipo
Descripción
filename
String
el nombre del archivo que le indica al navegador que debe usar
Volver
TextOutput: Es el objeto TextOutput, útil para encadenar.
Arroja
Error: Si el nombre del archivo contiene caracteres no permitidos
getContent()
Obtiene el contenido que se publicará.
Volver
String: Es el contenido que se publicará.
getFileName()
Muestra el nombre del archivo con el que se descargará este archivo o nulo si se debe mostrar en lugar de descargarse.
Volver
String: Es el nombre del archivo.
getMimeType()
Obtén el tipo de MIME con el que se publicará este contenido.
[[["Fácil de comprender","easyToUnderstand","thumb-up"],["Resolvió mi problema","solvedMyProblem","thumb-up"],["Otro","otherUp","thumb-up"]],[["Falta la información que necesito","missingTheInformationINeed","thumb-down"],["Muy complicado o demasiados pasos","tooComplicatedTooManySteps","thumb-down"],["Desactualizado","outOfDate","thumb-down"],["Problema de traducción","translationIssue","thumb-down"],["Problema con las muestras o los códigos","samplesCodeIssue","thumb-down"],["Otro","otherDown","thumb-down"]],["Última actualización: 2025-07-26 (UTC)"],[[["\u003cp\u003eA \u003ccode\u003eTextOutput\u003c/code\u003e object enables scripts to serve text content securely by redirecting the browser to \u003ccode\u003egoogleusercontent.com\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eIt offers methods to serve various content types such as JSON, RSS, and XML using the \u003ccode\u003eContentService\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can manipulate the output using methods like \u003ccode\u003eappend\u003c/code\u003e, \u003ccode\u003eclear\u003c/code\u003e, \u003ccode\u003edownloadAsFile\u003c/code\u003e, \u003ccode\u003egetContent\u003c/code\u003e, \u003ccode\u003egetFileName\u003c/code\u003e, \u003ccode\u003egetMimeType\u003c/code\u003e, \u003ccode\u003esetContent\u003c/code\u003e, and \u003ccode\u003esetMimeType\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eTextOutput\u003c/code\u003e enhances security by preventing direct return of text content to the browser from scripts.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003edownloadAsFile\u003c/code\u003e method enables content to be downloaded instead of displayed, offering flexibility in how the output is handled.\u003c/p\u003e\n"]]],["TextOutput objects allow scripts to serve text content, which browsers access via redirection to googleusercontent.com. Key actions include: `append()` to add content, `clear()` to erase content, `downloadAsFile()` to trigger downloads, `getContent()` to retrieve content, `getFileName()` and `getMimeType()` to get metadata. `setContent()` sets the content, and `setMimeType()` specifies the content type. Scripts can use it to create outputs in text, JSON, RSS, and XML formats.\n"],null,["TextOutput\n\nA TextOutput object that can be served from a script.\n\nDue to security considerations, scripts cannot directly return text content to a browser.\nInstead, the browser is redirected to googleusercontent.com, which will display it without any\nfurther sanitization or manipulation.\n\nYou can return text content like this:\n\n```javascript\nfunction doGet() {\n return ContentService.createTextOutput('hello world!');\n}\n```\nThere are also methods to serve JSON, RSS, and XML as TextOutputs; see the corresponding methods on [ContentService](/apps-script/reference/content/content-service). \n\nMethods\n\n| Method | Return type | Brief description |\n|-----------------------------------------------------|------------------------------------------------------|-----------------------------------------------------------------------------------------------------------|\n| [append(addedContent)](#append(String)) | [TextOutput](#) | Appends new content to the content that will be served. |\n| [clear()](#clear()) | [TextOutput](#) | Clears the current content. |\n| [downloadAsFile(filename)](#downloadAsFile(String)) | [TextOutput](#) | Tells browsers to download rather than display this content. |\n| [getContent()](#getContent()) | `String` | Gets the content that will be served. |\n| [getFileName()](#getFileName()) | `String` | Returns the file name to download this file as, or null if it should be displayed rather than downloaded. |\n| [getMimeType()](#getMimeType()) | [MimeType](/apps-script/reference/content/mime-type) | Get the mime type this content will be served with. |\n| [setContent(content)](#setContent(String)) | [TextOutput](#) | Sets the content that will be served. |\n| [setMimeType(mimeType)](#setMimeType(MimeType)) | [TextOutput](#) | Sets the mime type for content that will be served. |\n\nDetailed documentation \n\n`append(addedContent)` \nAppends new content to the content that will be served.\n\nParameters\n\n| Name | Type | Description |\n|------------------|----------|-----------------------|\n| `added``Content` | `String` | the content to append |\n\nReturn\n\n\n[TextOutput](#) --- this TextOutput itself, useful for chaining\n\n*** ** * ** ***\n\n`clear()` \nClears the current content.\n\nReturn\n\n\n[TextOutput](#) --- this TextOutput itself, useful for chaining\n\n*** ** * ** ***\n\n`download``As``File(filename)` \nTells browsers to download rather than display this content.\n\nSome browsers will ignore this setting. Setting this to null will clear it back to the\ndefault behavior of displaying rather than downloading.\n\nParameters\n\n| Name | Type | Description |\n|------------|----------|-----------------------------------------|\n| `filename` | `String` | the filename to tell the browser to use |\n\nReturn\n\n\n[TextOutput](#) --- the TextOutput object, useful for chaining\n\nThrows\n\n\n[`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) --- if the filename contains illegal characters\n\n*** ** * ** ***\n\n`get``Content()` \nGets the content that will be served.\n\nReturn\n\n\n`String` --- the content that will be served\n\n*** ** * ** ***\n\n`get``File``Name()` \nReturns the file name to download this file as, or null if it should be displayed rather than\ndownloaded.\n\nReturn\n\n\n`String` --- the file name\n\n*** ** * ** ***\n\n`get``Mime``Type()` \nGet the mime type this content will be served with.\n\nReturn\n\n\n[MimeType](/apps-script/reference/content/mime-type) --- the mime type this will be served with\n\n*** ** * ** ***\n\n`set``Content(content)` \nSets the content that will be served.\n\nParameters\n\n| Name | Type | Description |\n|-----------|----------|----------------------|\n| `content` | `String` | the content to serve |\n\nReturn\n\n\n[TextOutput](#) --- this TextOutput itself, useful for chaining\n\n*** ** * ** ***\n\n`set``Mime``Type(mimeType)` \nSets the mime type for content that will be served. The default is plain text.\n\nParameters\n\n| Name | Type | Description |\n|--------------|------------------------------------------------------|---------------|\n| `mime``Type` | [MimeType](/apps-script/reference/content/mime-type) | the mime type |\n\nReturn\n\n\n[TextOutput](#) --- this TextOutput itself, useful for chaining"]]